Safe Signals

pudge on 2003-09-23T03:37:45

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; exit; }

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.


Same problem here

Matts on 2003-09-23T07:44:42

I've blogged this one a few months ago, after struggling through the exact same nastiness.

Unfortunately I can't find it now. And google with site:use.perl.org doesn't seem to fare any better (perhaps there's a NOINDEX on the journal pages?)

Re:Same problem here

jordan on 2003-09-23T15:02:13

You are not going crazy. I recall seeing it. Well, maybe it's mass hysteria.

I found it! We aren't going crazy! Or, at least, there's no proof, yet.