sys._exit()
Donn Cave
donn at drizzle.com
Thu Aug 23 01:26:55 EDT 2001
Quoth Ignacio Vazquez-Abrams <ignacio at openservices.net>:
| On Wed, 22 Aug 2001, Chuck Esterbrook wrote:
...
|> What would be the motivation for a child process of a fork to _exit()
|> instead of exit()? e.g., why wouldn't the child wish to cleanup handlers,
|> flush stdio buffers, etc.? Does anyone use _exit()?
| Because then it would step all over the data of the parent, if it is still
| running.
Well, note that the fork runs in a separate address space and can't
modify the parent's state. But there are still issues. For example,
after a failed execve(2) you wouldn't want to flush C stdio buffers
on the way out, because that buffered data was copied from the parent -
imagine a bunch of disk files with extra copies of random chunks of
output. If the fork is actually writing its own files, then those
should be flushed explicitly prior to _exit.
And sys.exit() raises an exception that you probably don't want to
catch in the fork.
By the way, I think we're really talking about posix._exit() here,
there is no sys._exit().
Donn Cave, donn at drizzle.com
More information about the Python-list
mailing list