in reply to Timing out a traceroute
However I am still seeing a LONG period of hanging for some hosts that is happening AFTER the timeout is reached, and when the subroutine is trying to CLOSE the pipe.That's because perl is being too polite to the traceroute process whilst closing the pipe: it just sends SIGPIPE (see close) - which traceroute ignores - then waits till the other process closes the pipe, just in case you were interested in it's output.Why is this? By code is below
The piped open to a command returns that's processes PID.
You could use that to be unpolite and then close the pipe:
if( my $pid = open my $pipe, "traceroute -I -n $hostname |" ) { while(1) { last if ... } kill 2, $pid; close $pipe; }
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Timing out a traceroute
by vancetech (Beadle) on Sep 18, 2006 at 04:49 UTC |