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

Created on 2010-06-30 15:54 by zarkdav, last changed 2011-02-03 07:55 by ned.deily. This issue is now closed.

Messages (6)
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.
History
Date User Action Args
2011-02-03 07:55:02ned.deilysetstatus: open -> closed

nosy: + ned.deily
versions: + Python 2.7
messages: + msg127786

resolution: out of date
stage: committed/rejected
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