Python signal delivery under BSD 4.4

Elf M. Sternberg elf at
Wed Aug 13 23:40:54 CEST 2003

Donn Cave <donn at> writes:

> In article <m3bruuk080.fsf at>,
>  "Elf M. Sternberg" <elf at> wrote:

>>         This worked well under Python 2.1, where I used os.fork() instead
>> of os.spawnvp().

>>         We have upgraded to Python 2.2.3 and it has mysteriously stopped
>> working.  Processes launched off the appserver, whether using os.fork()
>> or os.spawnvp(), are now completely deaf to signals.  Nothing gets its
>> attention except, of course, SIGKILL.  Not when sent from the appserver,
>> and not when sent from the shell, not even by root.

        I'm sorry about the confusion.  FreeBSD 4.4 is what we're
running where I work.

> Can you duplicate it in a simpler environment?
> I'd like to run the following C program from spawnv, from a
> Python program like

>   import os
>   import time
>   import signal

>   p = os.spawnv(os.P_NOWAIT, 'prsig', ['prsig'])
>   time.sleep(1.0)
>   os.kill(p, signal.SIGTERM)
>   print 'process exit', os.waitpid(p, 0)

        I'm going to assume you meant 'SIGUSR1' here since that's what
you're catching in the C code you included.

        In any event, your code worked as expected.  

        However, this variant worked as I've reported:

import os
import sys
import time
import signal
import thread

def do_it():
    p = os.spawnv(os.P_NOWAIT, 'prsig', ['prsig'])
    print >>sys.stderr, "Sleeping"
    os.kill(p, signal.SIGUSR1)
    print 'process exit', os.waitpid(p, 0)

thread.start_new_thread(do_it, ())

        Not only did it behave as I reported, but it slept the full four
seconds even though the sys.exit() call was made.  This leads me to the
conclusion that something rather unusual is going on within Python's
threading module and the libc_r.a within FreeBSD4.4.

        Right now, I just want a way to make signal delivery work.

        Thanks for your help so far, though.


More information about the Python-list mailing list