os._exit(), os.kill(os.getpid(), 9)

Erno Kuusela erno at iki.fi
Wed Jan 26 12:41:30 EST 2000


>>>>> "gerrit" == Gerrit Holl <gerrit.holl at pobox.com> writes:

    gerrit> Hi, Are those two equal?

    gerrit> os._exit(127) os.kill(os.getpid(), 9)

no, the parent process can tell if you've been killed by a signal or not.

>>> def die(): 
...   if os.fork() == 0: os.kill(os.getpid(), 9)
... 
>>> def die2():
...   if os.fork() == 0: os._exit(127)
... 
>>> die()  
>>> os.wait()
(7003, 9)
>>> die2()
>>> os.wait()
(7004, 32512)

the os.W* functions can be used to extract sensible information out of
the status. it's works exactly the same way as in C, except W* aren't
macros...

  -- erno




More information about the Python-list mailing list