@@ -376,8 +376,8 @@ def command(self):
376
376
def kill_subprocesses (pid , include = lambda x : True ):
377
377
from subprocess import Popen , PIPE
378
378
import signal
379
- command = [
380
- 'ps' , '--ppid ' , str ( pid ), '--format ' , 'pid,cmd' , '--no-headers ' ]
379
+
380
+ command = [ 'ps' , '-e ' , '-o ' , 'ppid, pid,command ' ]
381
381
proc = Popen (command , stdout = PIPE , stderr = PIPE )
382
382
(stdout , stderr ) = proc .communicate ()
383
383
if proc .returncode != 0 :
@@ -386,10 +386,10 @@ def kill_subprocesses(pid, include=lambda x: True):
386
386
'{2}' .format (command , proc .returncode , stderr ))
387
387
388
388
for line in map (str .strip , stdout .splitlines ()):
389
- (pid , cmd ) = line .split (' ' , 1 )
390
- if include (cmd ):
391
- print "Killing PID={0} COMMAND={1}" .format (pid , cmd )
392
- os .kill (int (pid ), signal .SIGINT )
389
+ (cmd_ppid , cmd_pid , cmd ) = line .split (None , 2 )
390
+ if cmd_ppid == str ( pid ) and include (cmd ):
391
+ print "Killing PID={0} COMMAND={1}" .format (cmd_pid , cmd )
392
+ os .kill (int (cmd_pid ), signal .SIGINT )
393
393
394
394
395
395
def construct_command (args ):
0 commit comments