ports/153167: Problem with signals, threads, and subprocesses in python
Duncan Findlay
duncan at duncf.ca
Wed Dec 15 06:00:25 UTC 2010
>Number: 153167
>Category: ports
>Synopsis: Problem with signals, threads, and subprocesses in python
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Dec 15 06:00:22 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Duncan Findlay
>Release: 7.3
>Organization:
>Environment:
>Description:
The patch added to the python port intended to fix PR 131080 has the unintended consequence of blocking signals in any subprocess spawned from a thread. If you start a process in a Python thread, the process can not be killed. This is a serious issue for us as we frequently spawn sub-processes from within threads of our daemon applications, and we need to be able to kill them, if they run too long, or the daemon needs to shutdown, etc.
PR 131080: http://www.freebsd.org/cgi/query-pr.cgi?pr=131080
Original Python issue: http://bugs.python.org/issue1975
>How-To-Repeat:
This test case shows the problem:
http://bugs.python.org/file20047/thread_test.py
Also:
Example code (example.py):
import subprocess
import threading
def create():
sub = subprocess.Popen(
args=('sleep', '60'), cwd=None, env=None,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
close_fds=True)
print 'Started process %d' % (sub.pid,)
if __name__ == '__main__':
thr = threading.Thread(target=create)
thr.start()
thr.join()
Example output:
$ python example.py
Started process 90813
$ ps -p 90813
PID TT STAT TIME COMMAND
90813 p0 S 0:00.00 sleep 60
$ kill 90813
$ ps -p 90813
PID TT STAT TIME COMMAND
90813 p0 S 0:00.00 sleep 60
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list