D
David Knell
Hi -
I've the following bit of code in a scripts:
$SIG{CHLD} = 'IGNORE';
while (1) {
if ($fs->accept("127.0.0.1", $socket)) {
$pid = fork();
last if ((defined($pid)) && ($pid == 0));
}
}
...rest of code..
- roughly speaking, $fs is a thing with a listening socket; the loop
should wait
for connections, fork, the inbound connection is handled by ..rest of
code..
and the loop goes round indefinitely.
What actually happens is that, every now and again (like every few
days) the
main loop exist. No obvious errors appear on the console, and the
child
processes continue to run correctly until they terminate, which
implies that
the parent's not being killed.
As far as I can see, this shouldn't happen - if the fork fails, pid
should be
undefined; if it succeeds, $pid should be non-zero for the parent
process.
Either way, the parent process should go round the loop again.
I'm using perl 5.8.8, running on CentOS 5.0.
Anyone any ideas?
Thanks --
Dave
I've the following bit of code in a scripts:
$SIG{CHLD} = 'IGNORE';
while (1) {
if ($fs->accept("127.0.0.1", $socket)) {
$pid = fork();
last if ((defined($pid)) && ($pid == 0));
}
}
...rest of code..
- roughly speaking, $fs is a thing with a listening socket; the loop
should wait
for connections, fork, the inbound connection is handled by ..rest of
code..
and the loop goes round indefinitely.
What actually happens is that, every now and again (like every few
days) the
main loop exist. No obvious errors appear on the console, and the
child
processes continue to run correctly until they terminate, which
implies that
the parent's not being killed.
As far as I can see, this shouldn't happen - if the fork fails, pid
should be
undefined; if it succeeds, $pid should be non-zero for the parent
process.
Either way, the parent process should go round the loop again.
I'm using perl 5.8.8, running on CentOS 5.0.
Anyone any ideas?
Thanks --
Dave