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

Jonathan Pryor jonpryor at vt.edu
Tue Mar 15 15:26:56 EDT 2011

On Mar 15, 2011, at 2:57 PM, Tom Philpot wrote:
> 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.
> Is this a bug or by design?

The problem is the Process.ExitCode property. There's no way to retrieve this value except through the waitpid(2) (and related) system calls, so the process can't be fully disposed just in case the ExitCode property will be accessed.

That said, once the instance has been disposed, it shouldn't be necessary to keep anything open, and the child handles should be closed. Given that you _are_ using a `using` block, and thus disposing of the instance, it seems that this is likely a bug and that Process.Dispose() isn't fully closing all resources as it should.

(For that matter, the Process finalizer should also be disposing of unmanaged resources, and it looks like that isn't the case either).

Could you please file a bug?

 - Jon

More information about the Mono-devel-list mailing list