Guest_imported
New member
- Jan 1, 1970
- 0
This program is called "rout2.pl"!!!! I am telling you this so the system() call makes sense. This program causes a zombie every time I have to reconnect after getting disconnected. The entire program actualy consists of 4 seperate processes working together with two seperate perl progs talking through local loopback via sockets and one acting as a virtual hard drive so the entire
network of 20 progs can read and right to it. The virtual hard drive code is not listed. Stripped down code of perl prog #1 is listed below. Thanks....
#!/usr/bin/perl
use IO::Socket;
$returnaddr="localhost";
&Begin;
sub Begin {
$server="192.168.100.20";
$port = "2346";
$remote = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>$server,
PeerPort=>$port, LocalAddr=>$returnaddr, LocalPort=>$port, Reuse=>1);
if (!defined($remote)) {
&Noconnect;
}else{
print "-----I am connected on port: $port\n";
$remote->autoflush(1);
}
}
sub Noconnect {
print "Could not connect\n";
sleep 2;
&Begin;
}
#vcons request through server below#
$portb = 2345;
$maxconn = SOMAXCONN;
$server = IO::Socket::INET->new(Proto=>"tcp", LocalPort=>$portb,
Listen=>$maxconn, Reuse=>1) or die "Can't setup server\n";
print "-----I receive all requests. Listening on port: $portb\n";
die "fork fail: $!" unless defined($kid = fork);
if ($kid) {
close $server;
my $buf;
while (sysread($remote, $buf, 1) == 1) {
print $buf . "\n";
}
close $remote;
# kill the child process. But this doesn't
#seem to happen?
kill(TERM => $kid);
#this where the zombies get created
#call to restart prog to reconnect
system('perl', "rout2.pl"
;
exit;
} else {
#forward all from vcons#
#this is who the zombie is, this guy doesn't get closed
#out when the system() call is called to restart the
#program
while($client = $server->accept){
$client->autoflush(1);
$in = <$client ; #html parser made me minus the greater
print $client "\n\n";
close $client;
chomp($in);
chomp($in);
print $remote "$in";
}
close $remote;
exit;
}
Note: All zombies disapear after ctrl+c`ing the final open rout2.pl prog.
Any info on calling adisconnect without ctrl+c`ing would also be great. this would most likely have to be done by sending a specific packet that means "disonnect" which would force the prog into a disconnect routine. I tried this but it failed with more zombies. Is there an ultimate way to just destroy all zombies at any given time?
network of 20 progs can read and right to it. The virtual hard drive code is not listed. Stripped down code of perl prog #1 is listed below. Thanks....
#!/usr/bin/perl
use IO::Socket;
$returnaddr="localhost";
&Begin;
sub Begin {
$server="192.168.100.20";
$port = "2346";
$remote = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>$server,
PeerPort=>$port, LocalAddr=>$returnaddr, LocalPort=>$port, Reuse=>1);
if (!defined($remote)) {
&Noconnect;
}else{
print "-----I am connected on port: $port\n";
$remote->autoflush(1);
}
}
sub Noconnect {
print "Could not connect\n";
sleep 2;
&Begin;
}
#vcons request through server below#
$portb = 2345;
$maxconn = SOMAXCONN;
$server = IO::Socket::INET->new(Proto=>"tcp", LocalPort=>$portb,
Listen=>$maxconn, Reuse=>1) or die "Can't setup server\n";
print "-----I receive all requests. Listening on port: $portb\n";
die "fork fail: $!" unless defined($kid = fork);
if ($kid) {
close $server;
my $buf;
while (sysread($remote, $buf, 1) == 1) {
print $buf . "\n";
}
close $remote;
# kill the child process. But this doesn't
#seem to happen?
kill(TERM => $kid);
#this where the zombies get created
#call to restart prog to reconnect
system('perl', "rout2.pl"
exit;
} else {
#forward all from vcons#
#this is who the zombie is, this guy doesn't get closed
#out when the system() call is called to restart the
#program
while($client = $server->accept){
$client->autoflush(1);
$in = <$client ; #html parser made me minus the greater
print $client "\n\n";
close $client;
chomp($in);
chomp($in);
print $remote "$in";
}
close $remote;
exit;
}
Note: All zombies disapear after ctrl+c`ing the final open rout2.pl prog.
Any info on calling adisconnect without ctrl+c`ing would also be great. this would most likely have to be done by sending a specific packet that means "disonnect" which would force the prog into a disconnect routine. I tried this but it failed with more zombies. Is there an ultimate way to just destroy all zombies at any given time?