Martin Panter added the comment:
When no timeout is specified, these are the options as I see them:
1. SIGKILL child immediately on the first KeyboardInterrupt (Victor’s behaviour
since 3.3)
2. Give up and leave a zombie after the first KeyboardInterrupt (pre-3.3
behaviour)
3. Wait again after first KeyboardInterrupt, and leave a zombie after the
second one (Mike’s patch)
4. Ignore SIGINT so that by default no KeyboardInterrupt will happen, like C’s
system()
5. Start a timeout after the first KeyboardInterrupt (Victor’s suggestion)
Here is my proposal, taking into account Victor’s desire to never leave a
zombie, and Mike’s desire to let the child handle SIGINT in its own time: After
the first KeyboardInterrupt or other exception, wait() a second time, and only
use SIGKILL if the second wait() is interrupted. It’s a bit complicated, but I
think this would solve everyone’s concerns raised so far:
def call(*popenargs, timeout=None, **kwargs):
p = Popen(*popenargs, **kwargs)
try:
if timeout is None:
try:
return p.wait()
except:
p.wait() # Let the child handle SIGINT
raise
else:
return p.wait(timeout=timeout)
except:
p.kill() # Last resort to avoid leaving a zombie
p.wait()
raise
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue25942>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com