1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 21:21:31 +00:00

Make Zenmap use SIGTERM (instead of SIGKILL) for "Cancel Scan" so that Nmap has a chance to shutdown cleanly.

However, if Nmap is still running after 5 seconds, send a SIGKILL.
This commit is contained in:
jay
2014-06-28 09:59:00 +00:00
parent 1d0509f210
commit 9de9c77d91

View File

@@ -252,13 +252,22 @@ class NmapCommand(object):
def kill(self):
"""Kill the nmap subprocess."""
from time import sleep
log.debug(">>> Killing scan process %s" % self.command_process.pid)
if sys.platform != "win32":
try:
from signal import SIGKILL
os.kill(self.command_process.pid, SIGKILL)
self.command_process.wait()
from signal import SIGTERM, SIGKILL
os.kill(self.command_process.pid, SIGTERM)
for i in range(10):
sleep(0.5)
if self.command_process.poll() is not None: # Process has been TERMinated
break
else:
log.debug(">>> SIGTERM has not worked even after waiting for 5 seconds. Using SIGKILL.")
os.kill(self.command_process.pid, SIGKILL)
self.command_process.wait()
except:
pass
else: