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

Created on 2010-12-06 00:05 by joseph.h.garvin, last changed 2011-06-23 16:45 by rosslagerwall. This issue is now closed.

Messages (2)
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

Popen('/bin/ech')

or somesuch.
History
Date User Action Args
2011-06-23 16:45:14rosslagerwallsetstatus: pending -> closed
2010-12-06 07:37:51georg.brandlsetstatus: open -> pending

nosy: + georg.brandl
messages: + msg123459

resolution: invalid
2010-12-06 00:05:24joseph.h.garvincreate