Safe Signals

| | Comments (0)
This wasted a significant amount of my time today:

$SIG{CHLD} = sub { 1 };
my $sock = new IO::Socket::INET (
    LocalPort    => 2305,
    Type        => SOCK_STREAM,
    Proto        => 'tcp',
    Reuse        => 1,
    Listen        => 10,
) or die "Could not start server: $!.\n";
while (my $child = $sock->accept) {
    next if fork;
print "huh?";

Now, one would think that the while loop should just merrily continue along from child to child, but instead -- apparently because of a problem in IO::Socket itself, resulting from the new safe signals in perl 5.8.0 -- the SIGCHLD is improperly interpreted as a SIGALRM and the while loop ends.

I fixed by adding a label FOO: in front of the while loop, and putting a goto FOO below it. Good enough for me.

Leave a comment

<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Entry

This page contains a single entry by pudge published on September 22, 2003 8:37 PM.

cenotaph-1.2 Released was the previous entry in this site.

Recall Followup is the next entry in this site.

Find recent content on the main index or look in the archives to find all content.