close file descriptors in process.close() and avoid leaving zombie processes around

(cherry picked from commit fa2e11391e)
This commit is contained in:
antoniob authored and Zach Riggle committed 2015-10-06 18:06:10 -04:00
1 parent 29eefaac2b
commit 442873e5be
1 file changed
+9
+9
View File
@@ -454,9 +454,18 @@ class process(tube):
# First check if we are already dead
self.poll()
#close file descriptors
if self.proc.stdin is not None:
self.proc.stdin.close()
if self.proc.stderr is not None:
self.proc.stderr.close()
if self.proc.stdout is not None:
self.proc.stdout.close()
if not self._stop_noticed:
try:
self.proc.kill()
self.proc.wait() #avoid leaving zombies around
self._stop_noticed = True
self.info('Stopped program %r' % self.program)
except OSError: