Hello all,
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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.