exception KeyboardInterrupt and os.system command

jepler at unpythonic.net jepler at unpythonic.net
Sun Nov 27 18:20:12 EST 2005


You can tell by the exit code from system() whether the subprocess
exited due to a signal.  Consider this code:
    import os
    while 1:
        print os.system("sleep 1")
unless you happen to hit ctrl-c at the right time, you'll see it print
"2" (and "0" when the sleep finishes).  The exit code can be interpreted
according to the waitpid manpage, though I am not sure where the Python
equivalent of the WIFSIGNALED and WTERMSIG macros are.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20051127/669a3518/attachment.sig>


More information about the Python-list mailing list