in reply to Re^2: Eval leaving zombies when dying with alarm
in thread Eval leaving zombies when dying with alarm
Actually, I think I'd use a different approach:
Or, you can use IO::Select: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);
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Eval leaving zombies when dying with alarm
by yogsothoth (Novice) on Apr 25, 2008 at 22:52 UTC |