|
|
@@ -92,6 +92,12 @@ class Process(object): |
|
|
|
except OSError: # pragma: no cover |
|
|
|
return None |
|
|
|
|
|
|
|
def kill(pid, sig): |
|
|
|
try: |
|
|
|
return os.kill(pid, sig) |
|
|
|
except OSError: # pragma: no cover |
|
|
|
return |
|
|
|
|
|
|
|
# Find all children |
|
|
|
group = getpgid(self._process.pid) |
|
|
|
main = psutil.Process(self._process.pid) |
|
|
@@ -100,7 +106,7 @@ class Process(object): |
|
|
|
# Kill with SIGTERM, if they're still in this process group |
|
|
|
for proc in allproc: |
|
|
|
if getpgid(proc.pid) == group: |
|
|
|
os.kill(proc.pid, signal.SIGTERM) |
|
|
|
kill(proc.pid, signal.SIGTERM) |
|
|
|
|
|
|
|
# Wait for it to die again |
|
|
|
if self._join(timeout): |
|
|
@@ -109,7 +115,7 @@ class Process(object): |
|
|
|
# One more try with SIGKILL |
|
|
|
for proc in allproc: |
|
|
|
if getpgid(proc.pid) == group: |
|
|
|
os.kill(proc.pid, signal.SIGKILL) |
|
|
|
kill(proc.pid, signal.SIGKILL) |
|
|
|
|
|
|
|
# See if it worked |
|
|
|
return self._join(timeout) |
|
|
|