how to catch signals

Quinn Dunkan quinn at mono.ugcs.caltech.edu
Sun Mar 5 20:36:18 EST 2000


Hello!  I have a process that starts children, and perhaps kills them at some
time.  The children need to be unregistered when they die, so I set up a
SIGCHLD handler that does so.  Unfortunately, the handler doesn't always get
called, and I want to know what the safest way to catch a SIGCHLD
'synchronously' after I kill (I can't just wait() afterwards, because it's
possible someone else killed it).
I changed things to:

class Job:
    ...
    def kill(self):
        sys.setcheckinterval(0)
        os.kill(self.pid)
        try: time.sleep(1)
        except: pass # IOError, interrupted system call
        sys.setcheckinterval(10)

Is this recommended?  Any other approaches?  I haven't been able to figure out
why the handler wasn't being called before...

thanks...



More information about the Python-list mailing list