Subject: | Running Net::Traceroute in a loop results in cumulative defunct traceroute processes |
Date: | Sun, 13 Sep 2015 23:43:13 +0800 |
To: | bug-Net-Traceroute [...] rt.cpan.org |
From: | Alvin Koh <alvin2038 [...] gmail.com> |
Hi,
Running Net::Traceroute in a loop results in cumulative defunct traceroute processes.
Net::Traceroute 1.15
Perl 5.18.2
Mac OS X 10.10.5 and SUSE Linux 11
Reproduction:
Run this script in a terminal session.
#!/usr/bin/perl
use Net::Traceroute;
while (1) {
$tr = Net::Traceroute->new(host => "203.116.165.172",
debuglvl => 9,
max_ttl => 2,
timeout => 1);
if($tr->found) {
my $hops = $tr->hops;
if($hops > 1) {
print "LAN Router IP is " .
$tr->hop_query_host($tr->hops - 1, 0) . "\n";
print "ISP Gateway IP is " .
$tr->hop_query_host($tr->hops, 0) . "\n";
}
}
sleep 30;
}
In another session window,
#!/bin/bash
while true
do
date;
ps -ef | grep "traceroute" | grep -v grep | grep -v perl
sleep 30
done
With each iteration of Net::Traceroute, the second session will show an additional defunct traceroute process.
On OS X:
Sun Sep 13 23:03:16 SGT 2015
Sun Sep 13 23:03:46 SGT 2015
501 17724 17723 0 11:03PM ttys000 0:00.00 (traceroute)
Sun Sep 13 23:04:16 SGT 2015
501 17724 17723 0 11:03PM ttys000 0:00.00 (traceroute)
501 17735 17723 0 11:04PM ttys000 0:00.00 (traceroute)
Sun Sep 13 23:04:46 SGT 2015
501 17724 17723 0 11:03PM ttys000 0:00.00 (traceroute)
501 17735 17723 0 11:04PM ttys000 0:00.00 (traceroute)
501 17744 17723 0 11:04PM ttys000 0:00.00 (traceroute)
Sun Sep 13 23:05:16 SGT 2015
501 17724 17723 0 11:03PM ttys000 0:00.00 (traceroute)
501 17735 17723 0 11:04PM ttys000 0:00.00 (traceroute)
501 17744 17723 0 11:04PM ttys000 0:00.00 (traceroute)
501 17755 17723 0 11:05PM ttys000 0:00.00 (traceroute)
On Linux:
Sun Sep 13 23:28:26 SGT 2015
Sun Sep 13 23:28:56 SGT 2015
root 15589 15588 0 23:28 pts/0 00:00:00 [traceroute] <defunct>
Sun Sep 13 23:29:26 SGT 2015
root 15589 15588 0 23:28 pts/0 00:00:00 [traceroute] <defunct>
root 15598 15588 0 23:29 pts/0 00:00:00 [traceroute] <defunct>
Sun Sep 13 23:29:56 SGT 2015
root 15589 15588 0 23:28 pts/0 00:00:00 [traceroute] <defunct>
root 15598 15588 0 23:29 pts/0 00:00:00 [traceroute] <defunct>
root 15607 15588 0 23:29 pts/0 00:00:00 [traceroute] <defunct>
Best regards
Alvin