bae11208 has asked for the wisdom of the Perl Monks concerning the following question:
Hello i Use following Code, but it don't worke for me it generates Zombies and i can't kill the program. I need the return value from the shell programm, when a timeout occurs it should return Timeout
my $command='whatever.....'; my $status; eval { local $SIG{ALRM} = sub { die("dead\n"); }; alarm 2; my $status=`$command`; alarm(0); # turn off the alarm clock }; if($@){ if($@ eq "dead\n"){ $status='Timeout'; }else{ chomp($status); } } return $status;
I read many thinks, but found no soloution. Problem is i need the exit code from the shell command, so i can't change the code to fork/exec. Any hints or other solutions? The Main Program runs as an SNMP Agent, and i call external Programs that checks the System. I need the Timeout.....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need Function for Timing out shell commands
by ikegami (Patriarch) on Sep 14, 2011 at 22:15 UTC | |
|
Re: Need Function for Timing out shell commands
by eyepopslikeamosquito (Archbishop) on Sep 14, 2011 at 21:49 UTC | |
|
Re: Need Function for Timing out shell commands
by thewebsi (Scribe) on Sep 14, 2011 at 22:13 UTC | |
by salva (Canon) on Sep 15, 2011 at 08:07 UTC | |
|
Re: Need Function for Timing out shell commands
by cdarke (Prior) on Sep 15, 2011 at 07:40 UTC | |
|
Re: Need Function for Timing out shell commands
by salva (Canon) on Sep 15, 2011 at 07:54 UTC | |
by Anonymous Monk on Sep 15, 2011 at 16:55 UTC | |
by salva (Canon) on Sep 16, 2011 at 06:28 UTC |