This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Suggested change to _exit function description in os module documentation
Type: behavior Stage:
Components: Documentation Versions: Python 2.6, Python 2.5
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: loewis Nosy List: georg.brandl, gvanrossum, jtonsing, loewis
Priority: normal Keywords:

Created on 2007-09-12 18:23 by jtonsing, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg55853 - (view) Author: Johann Tonsing (jtonsing) Date: 2007-09-12 18:23
The document from which was 
generated contains:

"Note: The standard way to exit is sys.exit(n). _exit() should normally 
only be used in the child process after a fork()."

Should "child" be replaced with "parent"?

This also applies to:

Did not check the 3.0 docs (where can they be found?).
msg55856 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-09-12 18:54
Assigning to Martin.
msg55915 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-09-14 19:40
> Should "child" be replaced with "parent"?

No.  I'm pretty much I wrote that.  The use case I was thinking of is
the error handling in the child process after the exec fails.  if you
were to use sys.exit() there, which raises SystemExit, you're likely to
hit various exception handlers that were set up in the parent, and you
even run the risk of some main loop continuing *in the child*.  I've had
many a program produce the phenomenon of "double tracebacks" due to this

OTOH, in the parent, if you want to exit after forking (e.g. to create a
parent-less daemon process), a regular sys.exit() is usually just fine,
as any exception handlers you might trigger were meant to be triggered.
msg55921 - (view) Author: Johann Tonsing (jtonsing) Date: 2007-09-14 21:58
Thanks for explaining.

(FWIW I reported this because several examples / recipes I saw elsewhere 
on the net used os._exit() in the parent.  Perhaps they did this because 
they don't want to disrupt resources like file descriptors which the 
child has inherited or something.)
Date User Action Args
2022-04-11 14:56:26adminsetgithub: 45497
2007-09-14 21:58:03jtonsingsetmessages: + msg55921
2007-09-14 19:40:49gvanrossumsetstatus: open -> closed
nosy: + gvanrossum
resolution: rejected
messages: + msg55915
2007-09-12 18:54:29georg.brandlsetassignee: loewis
messages: + msg55856
nosy: + loewis, georg.brandl
2007-09-12 18:23:14jtonsingcreate