[csw-devel] SF.net SVN: gar:[20017] csw/mgar/gar/v2-yann/lib/python/inspective_package. py
chninkel at users.sourceforge.net
chninkel at users.sourceforge.net
Thu Jan 3 20:50:52 CET 2013
Revision: 20017
http://gar.svn.sourceforge.net/gar/?rev=20017&view=rev
Author: chninkel
Date: 2013-01-03 19:50:51 +0000 (Thu, 03 Jan 2013)
Log Message:
-----------
gar/v2-yann: also kill the children of the process launched when a timeout occurred
Modified Paths:
--------------
csw/mgar/gar/v2-yann/lib/python/inspective_package.py
Modified: csw/mgar/gar/v2-yann/lib/python/inspective_package.py
===================================================================
--- csw/mgar/gar/v2-yann/lib/python/inspective_package.py 2013-01-03 19:28:34 UTC (rev 20016)
+++ csw/mgar/gar/v2-yann/lib/python/inspective_package.py 2013-01-03 19:50:51 UTC (rev 20017)
@@ -11,6 +11,7 @@
import ldd_emul
import configuration as c
import time
+import signal
"""This file isolates code dependent on hachoir parser.
@@ -85,7 +86,8 @@
proc = subprocess.Popen(args,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
- env=env)
+ env=env,
+ preexec_fn=os.setsid)
# Python 3.3 have the timeout option
# we have to roughly emulate it with python 2.x
if timeout:
@@ -95,7 +97,9 @@
if proc.returncode is None:
time.sleep(0.1)
if time.time() >= max_time:
- proc.kill()
+ # we will all processes from the same process group
+ # in case the process spawned some children
+ os.kill(-proc.pid, signal.SIGKILL)
msg = "Process %s killed after timeout expiration" % args
raise TimeoutExpired(msg)
else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list