[Kimchi-devel] [PATCH] Github bug #326: run_command

Daniel Barboza danielhb at linux.vnet.ibm.com
Mon Feb 24 13:55:27 UTC 2014


From: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>

As described in https://github.com/kimchi-project/kimchi/issues/326,
run_command does not handle blocking process with timeout.

This patch fixes the bug, killing all children process of the process
created by Popen() call before executing kill() in the parent
process, making the timeout timer working as intended.

Please refer to the commit message of the patch for further details.

Using the same example described in the github bug entry to
demonstrate the fix:

$ sudo PYTHONPATH=src python
Python 2.7.5 (default, Nov 12 2013, 16:18:42)
[GCC 4.8.2 20131017 (Red Hat 4.8.2-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from kimchi.utils import run_command
>>> mount = ['mount', 'localhost:/var/nfs', '/home/danielhb/nfs_test/']
>>> run_command(mount, 7)
subprocess is killed by signal.SIGKILL for timeout 7 seconds
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/danielhb/kimchi/kimchi-upstream/src/kimchi/utils.py", line 181, in run_command
    raise TimeoutExpired("KCHUTILS0002E", msg_args)
kimchi.exception.TimeoutExpired: KCHUTILS0002E: Timeout while running command '['mount', 'localhost:/var/nfs', '/home/danielhb/nfs_test/']' after 7 seconds

ps output:

---- right after run_command started ----
[danielhb at tirion ~]$ ps axf  | grep mount
16664 pts/3    S+     0:00  |   |   \_ grep --color=auto mount
16660 pts/4    S+     0:00  |               \_ mount localhost:/var/nfs /home/danielhb/nfs_test/
16662 pts/4    D+     0:00  |                   \_ /sbin/mount.nfs localhost:/var/nfs /home/danielhb/nfs_test -o rw
[danielhb at tirion ~]$
---- after the timeout of 7 seconds ----
[danielhb at tirion ~]$ ps axf  | grep mount
16696 pts/3    S+     0:00  |   |   \_ grep --color=auto mount



*** BLURB HERE ***

Daniel Henrique Barboza (1):
  Github bug #326: run_command: killing all children processes

 src/kimchi/utils.py | 9 +++++++++
 1 file changed, 9 insertions(+)

-- 
1.8.3.1




More information about the Kimchi-devel mailing list