[Mono-dev] Process.Start and WaitForExit on MacOS X

Tom Philpot tom.philpot at logos.com
Tue Mar 15 14:57:02 EDT 2011


Regarding this post on Mono-OSX http://go-mono.com/forums/#nabble-td3251954 and some of my own issues with Process.Start() on MacOS X.

I've discovered that Process.Start(ProcessStartInfo info) leaves child processes hanging around until the parent process dies, unless you call WaitForExit() on the child process.
An alternative is to do something like this: (see above forum link for the rest of the code that this applies to).

using (var ioreg = Process.Start(ioregInfo)) {
ioreg.EnableRaisingEvents = true;
EventHandler handler;
handler = (s,e) => { ioreg.Exited -= handler; ioreg.WaitForExit(); };
ioreg.Exited += handler;
// Do something with the process
}

If you don't call WaitForExit() in some way on the process, the child processes hang around until the parent process dies and you end up with fork() returning –1 with an EAGAIN error code because you'll have exceeded the maximum number of processes allowed per uid.

Is this a bug or by design?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110315/7d1c03b7/attachment.html 


More information about the Mono-devel-list mailing list