Hi, fellow monks!
I stumbled over a problem I cant solve myself. This code works as its supposed on Linux, Solaris, OpenBSD.
#!/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;
}
}
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.
We have run of ideas where to look for the error, any hint is appreciated.
TIA,
Gnork
cat /dev/world | perl -e "(/(^.*? \?) 42\!/) && (print $1))"
errors->(c)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.