E
Ed
Trying to fork a socket server, but when file is transferred and child
exits the error:
Free to wrong pool 1e090e0 not 223fb0
Reasonable code facsimile:
$SIG{CHLD} = \&REAP;
my $sock = new IO::Socket::INET(
LocalPort => $port,
Proto => 'tcp',
Listen => SOMAXCONN,
Reuse => 1);
$sock or die "no socket : $!";
while ($client = $sock->accept()) {
if ($pid = fork) {
close $client;
} elsif (defined ($pid = fork)) {
# receive data
exit;
} else die "cannot fork";
}
sub REAP {
1 until (-1 == waitpid(-1, WNOHANG));
$SIG{CHLD} = \&REAP;
}
I must have missed something in the thousands of examples I reviewed.
ed
exits the error:
Free to wrong pool 1e090e0 not 223fb0
Reasonable code facsimile:
$SIG{CHLD} = \&REAP;
my $sock = new IO::Socket::INET(
LocalPort => $port,
Proto => 'tcp',
Listen => SOMAXCONN,
Reuse => 1);
$sock or die "no socket : $!";
while ($client = $sock->accept()) {
if ($pid = fork) {
close $client;
} elsif (defined ($pid = fork)) {
# receive data
exit;
} else die "cannot fork";
}
sub REAP {
1 until (-1 == waitpid(-1, WNOHANG));
$SIG{CHLD} = \&REAP;
}
I must have missed something in the thousands of examples I reviewed.
ed