1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 10:10:46 +00:00

Merge pull request #167 from valschneider/kill-children

host: Add kill_children utility method
This commit is contained in:
setrofim 2017-09-12 15:41:18 +01:00 committed by GitHub
commit a46f1038f8

View File

@ -14,6 +14,7 @@
# #
from glob import iglob from glob import iglob
import os import os
import signal
import shutil import shutil
import subprocess import subprocess
import logging import logging
@ -24,6 +25,11 @@ from devlib.utils.misc import check_output
PACKAGE_BIN_DIRECTORY = os.path.join(os.path.dirname(__file__), 'bin') PACKAGE_BIN_DIRECTORY = os.path.join(os.path.dirname(__file__), 'bin')
def kill_children(pid, signal=signal.SIGKILL):
with open('/proc/{0}/task/{0}/children'.format(pid), 'r') as fd:
for cpid in map(int, fd.read().strip().split()):
kill_children(cpid, signal)
os.kill(cpid, signal)
class LocalConnection(object): class LocalConnection(object):