Guest User

[Zenmap] Terminal Problem due to Nmap Runtime Interaction

a guest
Jun 26th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.23 KB | None | 0 0
  1. Index: zenmap/zenmapCore/NmapCommand.py
  2. ===================================================================
  3. --- zenmap/zenmapCore/NmapCommand.py    (revision 33093)
  4. +++ zenmap/zenmapCore/NmapCommand.py    (working copy)
  5. @@ -252,13 +252,22 @@
  6.  
  7.      def kill(self):
  8.          """Kill the nmap subprocess."""
  9. +        from time import sleep
  10. +
  11.          log.debug(">>> Killing scan process %s" % self.command_process.pid)
  12.  
  13.          if sys.platform != "win32":
  14.              try:
  15. -                from signal import SIGKILL
  16. -                os.kill(self.command_process.pid, SIGKILL)
  17. -                self.command_process.wait()
  18. +                from signal import SIGTERM, SIGKILL
  19. +                os.kill(self.command_process.pid, SIGTERM)
  20. +                for i in range(10):
  21. +                    sleep(0.5)
  22. +                    if self.command_process.poll() is not None: # Process has been TERMinated
  23. +                        break
  24. +                else:
  25. +                    log.debug(">>> SIGTERM has not worked even after waiting for 5 seconds. Using SIGKILL.")
  26. +                    os.kill(self.command_process.pid, SIGKILL)
  27. +                    self.command_process.wait()
  28.              except:
  29.                  pass
  30.          else:
Advertisement
Add Comment
Please, Sign In to add comment