(no subject)

Andrew Athan aathan-python-5923 at cloakmail.com
Tue Jan 6 02:22:28 CET 2004




I have a python program (snippet below) which does not want to seem to die
when I issue a sys.exit() inside the SIGTERM handler.  The output below is
generated as the result of sending several SIGTERM signals to the process,
as a result of seeing that it had not died.

I don't think this is relevant, but the application has fork()ed a child
process (cdparanoia).  The only thing I can think of is that somehow, there
is an exception occuring inside sys.exit(), otherwise why am I not seeing
the "Did not sys.exit()!?" output?  Could it be that exit() is returning but
that the output fd's are already closed?

Verrry strange...and therefore I'm sure I'm making a brain dead mistake.

Thanks in advance,
A.

--------------------------------------------------------------------------

****SIGTERM*****


****SIGTERM*****

..
****SIGCHILD*****


Ripper output status code: (4314, 15)
4320 /root/postprocess /var/music/ripper/8707620b

****SIGCHILD*****

Error JOB_NODISC in job <__main__.JobHandler instance at 0x8204b24>
4321 /bin/setserial /dev/ttyS0 spd_normal

****SIGCHILD*****



Killing child processes...

--------------------------------------------------------------------------

def sigterm(a,b):
    print '\n****SIGTERM*****\n'
    sys.exit()
    print '\nDid not sys.exit()??!!\n'
    killChildren()
    os._exit(1)
    print '\nDid not os._exit()??!!\n'

def killChildren():
    global childPIDs
    print '\n\nKilling child processes...'
    for pid in childPIDs:
        try:
            print 'Terminating %d'%pid
            os.kill(pid,signal.SIGTERM)
            os.waitpid(pid,0)
        except:
            pass

def child_exit(a,b):
    #childpid, status = os.wait()
    print '\n****SIGCHILD*****\n'
    pass





More information about the Python-list mailing list