in reply to Re^2: Parent process dies unexpected
in thread Parent process dies unexpected

First, I commented out the exit. It "fixed" the problem, but I deemed the solution unacceptable. Behold my fancy debugger!

#!/usr/bin/perl use strict; use IO::Socket; use constant MYPORT => 2000; $|=1; <------- my $sock = ''; my $client = ''; $sock = IO::Socket::INET->new(LocalPort => MYPORT, Type => SOCK_STREAM, Proto => 'tcp', Reuse => 1, Listen => 10) or die "trouble creating socket: $@\n"; $SIG{'CHLD'} = sub { print('!'); <------- wait(); print('@'); <------- $client->close(); print('#'); <------- }; print "Accepting connections on Port ", MYPORT, "...\n"; while ($client = $sock->accept()) { print "Accepted connection from ", $client->peerhost(), ":", $client->peerport(), "\n"; if (fork() == 0) { while (<$client>) { chomp; print $client scalar(reverse($_)), "\n"; } exit 1; } } print('$'); <------- print(0+$!, "$!"); <-------

When I noticed '!@#' was being printed, I added '$'. Then I checked why accept was returning by adding a print of $!.

Since I'm not sure what the cause is, I'm not sure if I consider it a bug. In any case, the behavious should be documented.

Replies are listed 'Best First'.
Re^4: Parent process dies unexpected
by gnork (Scribe) on Oct 01, 2004 at 11:12 UTC
    Hi, ikegami!

    Thx for your effort, we are digging in a bit deeper now.
    Maybe the weekend brings some new results which i will promptly let you know.

    Have a nice weekend,
    Gnork

    cat /dev/world | perl -e "(/(^.*? \?) 42\!/) && (print $1))"
    errors->(c)