gnork has asked for the wisdom of the Perl Monks concerning the following question:
However, under Perl 5.8.5 on FreeBSD 4.10 the parent process is killed as soon as the child closes the socket. Strangely enough, its running fine under perl 5.00503 which is Standard with FreeBSD 4.10. Before I forget, perl 5.8.5 was compiled from the ports.#!/usr/bin/perl use strict; use IO::Socket; use constant MYPORT => 2000; 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 { wait(); $client->close(); }; 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; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parent process dies unexpected
by ikegami (Patriarch) on Sep 28, 2004 at 15:17 UTC | |
by gnork (Scribe) on Sep 29, 2004 at 07:23 UTC | |
by ikegami (Patriarch) on Sep 29, 2004 at 13:59 UTC | |
by gnork (Scribe) on Oct 01, 2004 at 11:12 UTC |