For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > May 2004 > Net::Telnet, fork and signals..









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Net::Telnet, fork and signals..
Tarak Parekh

2004-05-17, 9:30 pm

Hello,

I've been trying to figure this out for the past couple of days but
am hitting a wall.

I am using Net::Telnet 3.03 with a modification in which
the SIGINT is sent on the wire to the remote command being run.

The short of the script is:

-----
$host1 = new Net::Telnet("host-A");
# Successfully did a open/login


if ($pid = fork) {
# Parent process
# do something that does not involve $host1 or $host2
} else {
# Child process
$host2 = new Net::Telnet("host-A");

# Successfully did a open/login

$host2 -> cmd(<A blocking command, lets say sleep 1000> );
exit 1;
}

# Kill the child process
kill 'INT' $pid;
$rval = waitpid($pid, &WNOHANG);

# Invoke a command on host-A
$host1 -> cmd (<A short command, lets say sleep 10> );
------

The last line of the script times-out within 11 seconds, and I do not
see that command being executed on host-A (by listing the processes
on host-A).

I've tried moving the last line before the "kill", but it has not helped.

I am unable to figure out the problem. Any ideas?

thanks,
tarak
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com