Somehow, it appears I'm getting an
ECHILD from
select(), which makes no sense to me. I'm writing a server that forks child processes to handle requests. They then exit. The server assigns a signal handler to
SIGCHLD to reap dead children, per
perlipc.
$SIG{CHLD}=\&reaper;
...
sub reaper
{
1 while waitpid -1,&POSIX::WNOHANG != -1;
$SIG{CHLD}=\&reaper;
}
If anywhere, this is where an
ECHILD would make more sense. Instead, it shows up in the server's main loop, which is the following.
use Errno;
...
$select=new IO::Select();
$select->add(...);
...
while (1) {
$!=undef;
while (@ready=$select->can_read()) {
handle($_) foreach @ready;
}
die if $select->count() == 0; #should always have at least one
last unless $! == EINTR; #try again; interrupted by signal
}
die if $! == ECHILD;
The weird part is that the
die at the end actually executes. How can this be? I thought
ECHILD occurred only in
wait() and
waitpid(). I understand that
system, piped opens, etc. do their own waiting and can generate
ECHILD, but how can that error code ever show up where I'm seeing it?
For further background, I'm on RedHat Linux 4.5, running Perl 5.8.5. All sockets involved are IO::Sockets set to block.
This is just weird.
Jim
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.