2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-07-29 15:51:18 +00:00

Task 46440 Cleanup the nmap process for switchdiscover command

This commit is contained in:
Casandra Qiu
2015-06-09 13:40:12 -04:00
parent 28bc448908
commit 75491b75aa

View File

@@ -627,6 +627,16 @@ sub nmap_scan {
}
}
# handle ctrl-c
$SIG{TERM} = $SIG{INT} = sub {
#clean up the nmap processes
my $nmap_pid = `ps -ef | grep nmap | grep -v grep | awk '{print \$2}'`;
if ($nmap_pid) {
system("kill -9 $nmap_pid >/dev/null 2>&1");
exit 0;
}
};
$ccmd = "/usr/bin/nmap -sP -oX - @$ranges";
my $result = xCAT::Utils->runcmd($ccmd, 0);
if ($::RUNCMD_RC != 0)