[issue9535] Pending signals are inherited by child processes

Greg Brockman report at bugs.python.org
Fri Aug 6 16:43:15 CEST 2010


New submission from Greg Brockman <gdb at mit.deu>:

Upon os.fork(), pending signals are inherited by the child process.  This can be demonstrated by pressing C-c in the middle of the
following program:

"""
import os, sys, time, threading
def do_fork():
    while True:
        if not os.fork():
            print 'hello from child'
            sys.exit(0)
        time.sleep(0.5)
t = threading.Thread(target=do_fork)
t.start()
t.join()
"""
Right after os.fork(), each child will raise a KeyboardInterrupt exception.

This behavior is different from the semantics of POSIX fork(), where child processes do not inherit their parents' pending signals.

Attached is a first stab at a patch to fix this issue.  Please let me know what you think!

----------
components: Extension Modules
files: signals.patch
keywords: patch
messages: 113104
nosy: gdb
priority: normal
severity: normal
status: open
title: Pending signals are inherited by child processes
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7
Added file: http://bugs.python.org/file18416/signals.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9535>
_______________________________________


More information about the Python-bugs-list mailing list