On Mon, Sep 09, 2002 at 03:07:38PM -0400, Peter Chen wrote:
> On Mon, 2002-09-09 at 12:07, Rocco Caputo wrote:
> > If DESTROY is being called, it's almost certain that the socket is
> > being destroyed from POE's point of view. Sockets still won't close
> > if something outside POE has copies of them. That includes child
> > processes, so this may be related to the Wheel::Run issues in the
> > other thread.
>
> Eureka! Thank you for pointing this out. Now it all makes sense.
>
> In order to handle individual requests, my daemon forks child processes
> (which are Perl functions run by POE::Wheel::Run), these child processes
> held on to the sockets of all connections at the time. That's why the
> clients were hanging until all those children exit, *sigh*.
>
> Now I just have to figure out how to close all file descriptors > $^F in
> the child process as you suggested.
Technically this should only be an issue if you're using the
functional form of Program. The others include exec() and ought not
be an issue, although they seem to be in practice, at least on some
systems.
Here's a way to close files above $^F. It's not pretty, not tested,
and may not be very portable. The code would go into Wheel::Run, just
before the function is called in the child process.
# Assuming 255 open handles max.
use POSIX qw(close);
for my $fd ($^F+1..255) {
POSIX::close($fd);
}
It should probably be made optional but on by default, probably
controlled by a CloseOnExec option.
-- Rocco Caputo / [EMAIL PROTECTED] / poe.perl.org / poe.sf.net