Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pudge (1)

pudge
  (email not shown publicly)
http://pudge.net/
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Monday September 22, 2003
10:37 PM

Safe Signals

[ #14847 ]

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • 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?)