well, using signals from perl is not always a safe operation.
The problem in your case is probably that at the low level, inside the perl interpreter, the die statement long-jumps over the cleanup code of the backtick operator where the pipes used to communicate with the slave process are closed.
There isn't an easy workaround. Maybe some module on CPAN would do it... though you should check that it doesn't use alarm internally.
A safe (untested) way to do it in perl is:
open my $pipe, "traceroute ... |" or die;
my $start = time;
my $buf = '';
while(1) {
my $vin = '';
vec($vin, fileno($pipe), 1) = 1;
if (select($vin, undef, undef, 1)) {
sysread $pipe, $buf, 2048, length $buf
or last;
}
last if time - $start > $timeout;
}
close $pipe;
# traceroute output is in $buf now
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.