Apparently those processes are not zombies. You'll need to
kill the
tcpdump process when the alarm goes off, and in order to do that you'll need to know its pid.
Actually, I think I'd use a different approach:
my $pid = open(T, "tcpdump ...|");
eval {
while (1) {
$SIG{ALRM} = sub { die "time to stop" }
alarm(20);
my $line = <T>; # read a line from tcpdump
alarm(0);
last unless defined($line);
# process line
}
};
kill 9, $pid;
close(T);
Or, you can use
IO::Select:
my $pid = open my $T, "tcpdump ...|";
my $sel = new IO::Select($T);
my $buf;
while ($sel->can_read($T, 20)) {
read($T, $buf, 1024, length($buf)) or last;
}
kill 9, $pid;
close($T);
# $buf contains output from tcpdump
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.