Can I get the exit code "n" passed to sys.exit(n) ?

Yujo yujorodrigues at gmail.com
Tue Apr 10 14:15:57 EDT 2007


Hello everybody,

In the following code of the finish() function, is there any way to
get the exit code passed to sys.exit() ?

def finish() :
   RETURN_CODE_FROM_SYS_EXIT = ????    # how can I get it ?
   if RETURN_CODE_FROM_SYS_EXIT = 0 :
     # process ended OK
   else :
     # process ended with some error
     # execute something

atexit.register(finish)

# this is my main program....

ERR_CODE=3
sys.exit(ERR_CODE)


Regards,

Yujo




More information about the Python-list mailing list