Check start time of child processes

pull/510/head
NextTurn 2018-11-29 00:00:00 +08:00 committed by Next Turn
parent f43e3bb6ab
commit 236bd0b778
1 changed files with 8 additions and 2 deletions

View File

@ -21,12 +21,18 @@ namespace winsw.Util
/// </summary>
/// <param name="processId">Process PID</param>
/// <returns>List of child process PIDs</returns>
private static unsafe List<Process> GetChildProcesses(int processId)
private static unsafe List<Process> GetChildProcesses(DateTime startTime, int processId)
{
var children = new List<Process>();
foreach (Process process in Process.GetProcesses())
{
if (process.StartTime <= startTime)
{
process.Dispose();
continue;
}
IntPtr handle;
try
{
@ -118,7 +124,7 @@ namespace winsw.Util
{
StopProcess(process, stopTimeout);
foreach (Process child in GetChildProcesses(process.Id))
foreach (Process child in GetChildProcesses(process.StartTime, process.Id))
{
StopProcessTree(child, stopTimeout);
}