-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Better document that process::exit does not result in a clean shutdown #28058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Which output buffers are not flushed? We register atexit handlers to take care of the global stdout buffer: https://github.com/rust-lang/rust/blob/master/src/libstd/io/lazy.rs#L53, and stderr is unbuffered. |
|
That seems like a bug in rt::atexit: #28065 |
Given that the bug has been fixed, I'm going to give this a close. Please let me know if that's still wrong. |
The documentation states
If a clean shutdown is needed it is recommended to only call this function at a known point where there are no more destructors left to run.
, however simply running it when no more destructors are left to run does not guarantee a clean exit. For example, output buffers are not flushed, as opposed to normal program termination. There might be other things thatprocess::exit
does not do that normal program termination does that I'm not aware of. These too should be documented. Or at the least, the documentation should not imply that if you runprocess::exit
when there are no more destructors left to run, you get a clean exit.Furthermore,
process::exit
should not be recommended as a mechanism for simply setting the exit code.env::set_exit_status
was deprecated with the messageDeprecated since 1.2.0: use process::exit instead
, then removed.process::exit
is simply not a good alternative. There are valid reasons for setting the exit code without abormal program termination.Examples:
The text was updated successfully, but these errors were encountered: