mirror of https://github.com/2dust/v2rayN
Bug fix for ProcUtils
parent
6c6de1ae7f
commit
a176613119
|
@ -81,9 +81,7 @@ public static class ProcUtils
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var procId = review ? proc?.Id : null;
|
GetProcessKeyInfo(proc, review, out var procId, out var fileName, out var processName);
|
||||||
var fileName = review ? proc?.MainModule?.FileName : null;
|
|
||||||
var processName = review ? proc?.ProcessName : null;
|
|
||||||
|
|
||||||
try { proc?.Kill(true); } catch (Exception ex) { Logging.SaveLog(_tag, ex); }
|
try { proc?.Kill(true); } catch (Exception ex) { Logging.SaveLog(_tag, ex); }
|
||||||
try { proc?.Kill(); } catch (Exception ex) { Logging.SaveLog(_tag, ex); }
|
try { proc?.Kill(); } catch (Exception ex) { Logging.SaveLog(_tag, ex); }
|
||||||
|
@ -91,6 +89,29 @@ public static class ProcUtils
|
||||||
try { proc?.Dispose(); } catch (Exception ex) { Logging.SaveLog(_tag, ex); }
|
try { proc?.Dispose(); } catch (Exception ex) { Logging.SaveLog(_tag, ex); }
|
||||||
|
|
||||||
await Task.Delay(300);
|
await Task.Delay(300);
|
||||||
|
await ProcessKillByKeyInfo(review, procId, fileName, processName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void GetProcessKeyInfo(Process? proc, bool review, out int? procId, out string? fileName, out string? processName)
|
||||||
|
{
|
||||||
|
procId = null;
|
||||||
|
fileName = null;
|
||||||
|
processName = null;
|
||||||
|
if (!review) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
procId = proc?.Id;
|
||||||
|
fileName = proc?.MainModule?.FileName;
|
||||||
|
processName = proc?.ProcessName;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logging.SaveLog(_tag, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task ProcessKillByKeyInfo(bool review, int? procId, string? fileName, string? processName)
|
||||||
|
{
|
||||||
if (review && procId != null && fileName != null)
|
if (review && procId != null && fileName != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -106,7 +106,13 @@
|
||||||
if (Utils.IsWindows())
|
if (Utils.IsWindows())
|
||||||
{
|
{
|
||||||
_processJob ??= new();
|
_processJob ??= new();
|
||||||
_processJob?.AddProcess(processHandle);
|
try
|
||||||
|
{
|
||||||
|
_processJob?.AddProcess(processHandle);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,6 +258,7 @@ namespace ServiceLib.Handler
|
||||||
proc.BeginErrorReadLine();
|
proc.BeginErrorReadLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppHandler.Instance.AddProcess(proc.Handle);
|
||||||
if (proc.WaitForExit(1000))
|
if (proc.WaitForExit(1000))
|
||||||
{
|
{
|
||||||
proc.CancelErrorRead();
|
proc.CancelErrorRead();
|
||||||
|
|
Loading…
Reference in New Issue