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

kyosohma at gmail.com kyosohma at gmail.com
Tue Apr 10 20:23:37 CEST 2007


On Apr 10, 1:15 pm, "Yujo" <yujorodrig... at gmail.com> wrote:
> 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

I'm not sure if this will help or not, but this article is pretty
enlightening and is written by a well-known Pythonista:

http://www.artima.com/weblogs/viewpost.jsp?thread=4829

Here is another older post with helpful information:
http://www.daniweb.com/techtalkforums/thread31226.html

And here's a hack that might work: http://www.daniweb.com/techtalkforums/thread31166.html

Mike




More information about the Python-list mailing list