Description
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 that process::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 run process::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 message Deprecated 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:
- Incorrect command line argument: Print help, set exit status to non-zero. Clean exit.
- File stated in command line argument does not exist. State this to the user, set exit status to non-zero. Clean exit.