1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-08 05:31: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): def kill(self):
"""Kill the nmap subprocess.""" """Kill the nmap subprocess."""
from time import sleep
log.debug(">>> Killing scan process %s" % self.command_process.pid) log.debug(">>> Killing scan process %s" % self.command_process.pid)
if sys.platform != "win32": if sys.platform != "win32":
try: try:
from signal import SIGKILL from signal import SIGTERM, SIGKILL
os.kill(self.command_process.pid, SIGKILL) os.kill(self.command_process.pid, SIGTERM)
self.command_process.wait() 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: except:
pass pass
else: else: