diff --git a/src/WinSW/WrapperService.cs b/src/WinSW/WrapperService.cs
index 174f024..6fd51c7 100644
--- a/src/WinSW/WrapperService.cs
+++ b/src/WinSW/WrapperService.cs
@@ -532,6 +532,9 @@ namespace WinSW
}
}
+ ///
+ /// will not be raised if is .
+ ///
private Process StartProcess(string executable, string? arguments, LogHandler? logHandler = null, Action? onExited = null)
{
var startInfo = new ProcessStartInfo(executable, arguments)
@@ -588,9 +591,16 @@ namespace WinSW
{
process.Exited += (sender, _) =>
{
+ Process process = (Process)sender!;
+
+ if (!process.EnableRaisingEvents)
+ {
+ return;
+ }
+
try
{
- onExited((Process)sender!);
+ onExited(process);
}
catch (Exception e)
{