Caller of Exited event should wait for process to exit in background.
authorKonrad M. Kruczynski <kkruczynski@antmicro.com>
Wed, 18 Nov 2015 12:44:49 +0000 (13:44 +0100)
committerKonrad M. Kruczynski <kkruczynski@antmicro.com>
Wed, 18 Nov 2015 12:44:49 +0000 (13:44 +0100)
Otherwise simply adding an event will make our program to live at least as long
as the created process lives.

mcs/class/System/System.Diagnostics/Process.cs

index f51dc2616006918a4780d9e3ec4c6c8086c8cd8e..76f2a7fc1a6ab69c601858faa71724530c122d29 100644 (file)
@@ -1584,7 +1584,7 @@ namespace System.Diagnostics {
                        if (background_wait_for_exit_thread != null)
                                return;
 
-                       Thread t = new Thread (_ => WaitForExit ());
+                       Thread t = new Thread (_ => WaitForExit ()) { IsBackground = true };
 
                        if (Interlocked.CompareExchange (ref background_wait_for_exit_thread, t, null) == null)
                                t.Start ();