shrubbery has asked for the wisdom of the Perl Monks concerning the following question:
I built a class that's main purpose is to execute various commands via backticks. I then check $? to see what happens afterwards and return it back through the method.
Anyway, I have a very strange problem. One command seems to time out all the time. But after EXACTLY 56 timeouts of this certain command, it refuses to run anymore and returns $? as -1 and blank in stdout and stderr.
The code is almost straight from the Perl Cookbook.
$SIG{ALRM} =\&time_out; eval { alarm $time_out; @args = `$command 2>&1`; alarm (0); }; if ($@) { $err = 100; } # error codes from wait are bit shifted # if its 100, we timed out $err = ($? >> 8) if ($err != 100); sub time_out{ # Error: Timeout on process alarm 0; die; } return ({err => $err, data => \@args});
Any ideas?
Edit kudra, 2001-11-07 Added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: timeout process problems
by bluto (Curate) on Nov 07, 2001 at 05:58 UTC | |
by shrubbery (Acolyte) on Nov 07, 2001 at 20:18 UTC | |
by shrubbery (Acolyte) on Nov 08, 2001 at 00:42 UTC | |
by bluto (Curate) on Nov 08, 2001 at 01:50 UTC |