mirror of
https://github.com/netchx/netch.git
synced 2026-05-11 23:45:06 +08:00
Update TryReleaseUsedTcpPort
This commit is contained in:
@@ -193,9 +193,10 @@ namespace Netch.Controllers
|
|||||||
{
|
{
|
||||||
foreach (var p in PortHelper.GetProcessByUsedTcpPort(port))
|
foreach (var p in PortHelper.GetProcessByUsedTcpPort(port))
|
||||||
{
|
{
|
||||||
|
string fileName;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_ = p.MainModule!.FileName;
|
fileName = p.MainModule!.FileName;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -203,16 +204,14 @@ namespace Netch.Controllers
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p.MainModule.FileName.StartsWith(Global.NetchDir))
|
if (fileName.StartsWith(Global.NetchDir))
|
||||||
{
|
{
|
||||||
p.Kill();
|
p.Kill();
|
||||||
p.WaitForExit();
|
p.WaitForExit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new MessageException(i18N.TranslateFormat("The {0} port is used by {1}.",
|
throw new MessageException(i18N.TranslateFormat("The {0} port is used by {1}.", $"{portName} ({port})", $"({p.Id}){fileName}"));
|
||||||
$"{portName} ({port})",
|
|
||||||
$"({p.Id}){p.MainModule.FileName}"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user