On Wed, Oct 29, 2008 at 4:02 AM, Hongli Lai <hongli / plan99.net> wrote:
> Robert Klemme wrote:
>>
>> ObjectSpace does create some issues for JRuby IIRC, so maybe we should
>> consider whether we can get rid of it without too many disadvantages.
>
> There's at least one important use case for ObjectSpace: closing all open IO
> objects. This is very important for daemonizing a process.
>
> For example, Phusion Passenger's spawn manager calls fork(), after which it
> closes all file descriptors with C code. This turns out not to be enough:
> the resulting process may raise Errno::EBADFD at very strange and unexpected
> times. This is caused by the fact that there are still Ruby IO objects that
> think that the file descriptors are open, and thus any operations on those
> file descriptors will result in errors. This was fixed by performing:

This is very interesting.  I may have run into something similar to it
before.  Do you have an example of it?
Why do you close all file descriptors after fork?
Thanks!
-=R