[Mono-devel-list] monod: System.ServiceProcess on Linux

Miguel de Icaza miguel at ximian.com
Sat Apr 2 14:43:05 EST 2005


> I don't know if it's possible to do the fork in managed
> code. The comment on fork in Mono.Unix doesn't look 
> encouraging.

The only reason why fork() is a bad idea from Mono and from any other
relatively large framework is that after the fork the programmer has to
take responsibility for the file descriptors that might have been
allocated by the framework.

Not every framework documents what to do with their file descriptors,
nor do they provide ways of resetting the file descriptors to something
sane (GUI toolkits are the major infringer of this).

So a simplistic answer is: close all file descriptors above 2, and exec
as soon as you can without any interesting calls and you will be safe.  

This sadly takes a lot of power away.


More information about the Mono-devel-list mailing list