Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Dec 2010 05:52:23 GMT
From:      Duncan Findlay <duncan@duncf.ca>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/153167: Problem with signals, threads, and subprocesses in python
Message-ID:  <201012150552.oBF5qNhV087982@red.freebsd.org>
Resent-Message-ID: <201012150600.oBF60MeJ082326@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012150552.oBF5qNhV087982>