Skip to content

Commit

Permalink
Handle SystemException instead of InvalidOperationException in ChildP…
Browse files Browse the repository at this point in the history
…rocess.Kill().

Part of #139.
  • Loading branch information
alexrp committed Jan 8, 2024
1 parent 9897234 commit e371091
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/Processes/ChildProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,13 @@ public void Kill(bool entireProcessTree = true)
{
_process.WaitForExit();
}
catch (InvalidOperationException)
catch (SystemException)
{
// The process is already gone. This exception is undocumented but happens in practice.
// This method can theoretically throw a wide array of exceptions on Windows because of an internal call to
// Marshal.ThrowExceptionForHR() after a Win32 DuplicateHandle() call.
//
// The documentation also states separately that Win32Exception is a possibility, but it is unclear where
// that would come from. (But it derives from SystemException anyway.)
}
}
}

0 comments on commit e371091

Please sign in to comment.