mirror of https://github.com/winsw/winsw
Check start time of child processes
parent
f43e3bb6ab
commit
236bd0b778
|
@ -21,12 +21,18 @@ namespace winsw.Util
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="processId">Process PID</param>
|
/// <param name="processId">Process PID</param>
|
||||||
/// <returns>List of child process PIDs</returns>
|
/// <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>();
|
var children = new List<Process>();
|
||||||
|
|
||||||
foreach (Process process in Process.GetProcesses())
|
foreach (Process process in Process.GetProcesses())
|
||||||
{
|
{
|
||||||
|
if (process.StartTime <= startTime)
|
||||||
|
{
|
||||||
|
process.Dispose();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
IntPtr handle;
|
IntPtr handle;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -118,7 +124,7 @@ namespace winsw.Util
|
||||||
{
|
{
|
||||||
StopProcess(process, stopTimeout);
|
StopProcess(process, stopTimeout);
|
||||||
|
|
||||||
foreach (Process child in GetChildProcesses(process.Id))
|
foreach (Process child in GetChildProcesses(process.StartTime, process.Id))
|
||||||
{
|
{
|
||||||
StopProcessTree(child, stopTimeout);
|
StopProcessTree(child, stopTimeout);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue