S
Sébastien Cottalorda
Hi all,
Since I migrate a Perl Socket application from perl 5.6.0 to 5.8.0, I
encoutered problem with the $SIG{CHLD} interrupt.
Here is sample of my code (server side):
use IO::Socket;
my $port_recep=12345;
my ($server, $client);
my ($port,$iaddr);
my $server= IO::Socket::INET->new(LocalPort=> $port_recep,
Type=> SOCK_STREAM,
Reuse=>1,
Listen=>10)
or die "Couln\'t be a tcp server on $port_recep $@\n";
$SIG{CHLD} = sub { wait () };
while ($client=$server->accept()) {
$pid = fork ();
unless (defined($pid)) {
print "Impossible to fork : $!";
exit 1;
}
if ($pid == 0){
$port = $client->peerport();
$iaddr= $client->peerhost();
print "Connexion accepted from $iaddr on port $port\n";
# do the treatment ....
print "Son has finished\n";
close($client);
exit;
}
}
print "Father has finished. It\'s not normal\n";
close($server);
exit 0;
When a connexion cames, it was taken by the son, and the father dies just
after the son has finished his job.
If someone has a clue.
Thanks in advance.
Sébastien
Since I migrate a Perl Socket application from perl 5.6.0 to 5.8.0, I
encoutered problem with the $SIG{CHLD} interrupt.
Here is sample of my code (server side):
use IO::Socket;
my $port_recep=12345;
my ($server, $client);
my ($port,$iaddr);
my $server= IO::Socket::INET->new(LocalPort=> $port_recep,
Type=> SOCK_STREAM,
Reuse=>1,
Listen=>10)
or die "Couln\'t be a tcp server on $port_recep $@\n";
$SIG{CHLD} = sub { wait () };
while ($client=$server->accept()) {
$pid = fork ();
unless (defined($pid)) {
print "Impossible to fork : $!";
exit 1;
}
if ($pid == 0){
$port = $client->peerport();
$iaddr= $client->peerhost();
print "Connexion accepted from $iaddr on port $port\n";
# do the treatment ....
print "Son has finished\n";
close($client);
exit;
}
}
print "Father has finished. It\'s not normal\n";
close($server);
exit 0;
When a connexion cames, it was taken by the son, and the father dies just
after the son has finished his job.
If someone has a clue.
Thanks in advance.
Sébastien