Delivered signal info in exit status of a process?

Ishwar Rattan rattan at cps.cmich.edu
Fri Sep 24 14:52:08 EDT 2004


Here is a piece code (according to blurb on os.wait, the lower
order 7 bits of exit status of process should contain the signal
number of signal that terminated the process..) and signal number
should be 8 (SIGFPE), similar logic in C-code produces expected
result.

Any pointers?

-ishwar
----
import os

cpid = os.fork()
if cpid == 0:
    2 / 0          # divide by zero
else if cpid > 0:
     ps, st = os.wait()
     print 'child got signal: %d, exit status: %d' %(st&0177, st>>8)

prints::

child got signal: 0, exit status 1
---



More information about the Python-list mailing list