This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: subprocess.Popen.communicate() and SIGCHLD handlers
Type: enhancement Stage: resolved
Components: Documentation, Library (Lib) Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: 1731717 Superseder:
Assigned To: docs@python Nosy List: docs@python, exarkun, gregory.p.smith, ned.deily, rosslagerwall, terry.reedy, zarkdav
Priority: normal Keywords:

Created on 2010-06-30 15:54 by zarkdav, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg108990 - (view) Author: Benjamin Ryzman (zarkdav) Date: 2010-06-30 15:54
http://pastie.org/1025197

Is it deemed acceptable that setting up one's own SIGCHLD handler breaks communicate()?

I did not find it in the documentation.

With the above workaround one can mix communicate() processes with processes spawned in the background that one's too lazy to wait for.
msg108991 - (view) Author: Jean-Paul Calderone (exarkun) * (Python committer) Date: 2010-06-30 15:56
You should include all relevant issue materials here, in the Python issue tracker.  This ticket will be useless as soon as pastie.org decides to forget about your paste.
msg108992 - (view) Author: Benjamin Ryzman (zarkdav) Date: 2010-06-30 15:59
Content of the above pastie:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import signal
>>> import subprocess
>>> signal.signal(signal.SIGCHLD,signal.SIG_IGN)
0
>>> subprocess.Popen(["echo","blah"], stdout=subprocess.PIPE).communicate()[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/subprocess.py", line 698, in communicate
    self.wait()
  File "/usr/lib/python2.6/subprocess.py", line 1170, in wait
    pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
  File "/usr/lib/python2.6/subprocess.py", line 465, in _eintr_retry_call
    return func(*args)
OSError: [Errno 10] No child processes
>>> oldsignal = signal.signal(signal.SIGCHLD,signal.SIG_DFL)
>>> subprocess.Popen(["echo","blah"], stdout=subprocess.PIPE).communicate()[0]
'blah\n'
>>> signal.signal(signal.SIGCHLD,oldsignal)
0
msg113187 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-07 18:18
Can you suggest a specific doc patch with new text and location?
msg127784 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2011-02-03 05:14
This has been fixed in 2.7 and 3.2 so I think that this issue can be closed.
msg127786 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2011-02-03 07:55
Thanks for the problem report.  And thanks for noticing the fix.
msg153368 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2012-02-14 19:46
fixed via http://hg.python.org/cpython/rev/767420808a62
History
Date User Action Args
2022-04-11 14:57:03adminsetgithub: 53373
2012-02-14 19:46:49gregory.p.smithsetnosy: + gregory.p.smith
dependencies: + race condition in subprocess module
messages: + msg153368
2011-02-03 07:55:02ned.deilysetstatus: open -> closed

versions: + Python 2.7
nosy: + ned.deily

messages: + msg127786
resolution: out of date
stage: resolved
2011-02-03 05:14:39rosslagerwallsetnosy: + rosslagerwall
messages: + msg127784
2010-08-07 18:18:17terry.reedysetnosy: + terry.reedy

messages: + msg113187
versions: + Python 3.2, - Python 2.6
2010-06-30 15:59:28zarkdavsetmessages: + msg108992
2010-06-30 15:56:57exarkunsetnosy: + exarkun
messages: + msg108991
2010-06-30 15:56:47zarkdavsetassignee: docs@python

components: + Documentation, Library (Lib)
nosy: + docs@python
2010-06-30 15:54:55zarkdavcreate