Title: Calling subprocess.Popen with preexec_fn=signal.pause blocks forever
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, joseph.h.garvin, python-dev
Priority: normal Keywords:

Created on 2010-12-06 00:05 by joseph.h.garvin, last changed 2012-05-27 00:47 by python-dev. This issue is now closed.

Messages (3)
msg123444 - (view) Author: (joseph.h.garvin) Date: 2010-12-06 00:05
The following code will cause the interpreter to hang:

import subprocess
import signal
subprocess.Popen("/bin/echo", preexec_fn=signal.pause)

Replace "/bin/echo" with any valid program on your box, it's just the simplest Linux example. It's expected for signal.pause to block, but the documentation for Popen says that preexec_fn will be run in the /child/ process, so it shouldn't cause the interpreter running this code to block.

I'm going to guess Popen is using signals for some reason internally and signal.pause interferes with it. It's probably worth making sure that signals related functions work with preexec_fn in general.
msg123459 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-12-06 07:37
After forking, the parent waits for the child's exec call to determine if it succeeds.  Otherwise, you wouldn't get an exception in the parent when you do


or somesuch.
msg161693 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-05-27 00:47
New changeset e8d89503f061 by Terry Jan Reedy in branch 'default':
Merge with 3.2 #10635 whitespace
Date User Action Args
2012-05-27 00:47:16python-devsetnosy: + python-dev
messages: + msg161693
2011-06-23 16:45:14rosslagerwallsetstatus: pending -> closed
2010-12-06 07:37:51georg.brandlsetstatus: open -> pending

nosy: + georg.brandl
messages: + msg123459

resolution: not a bug
2010-12-06 00:05:24joseph.h.garvincreate