RFC: Add std::process::exit - #1011
Conversation
Add a new function to the `std::process` module to exit the process immediately with a specified exit code.
There was a problem hiding this comment.
s/destructor smany/destructors may/
There was a problem hiding this comment.
I think we should guarantee it. If we wish to make this not necessarily be true in the future, then I think that calls for adding a second function that explicitly bypasses rt::at_exit (and consequently is marked unsafe).
|
I'm sympathetic to the idea that we should let |
|
👍, although I find it mildly odd to put this in |
This is a good point, and I feel the same way! I'll add some text related to this in the RFC.
Our plan is to expand the module to also allow inspection of remote processes, sending signals, etc. In that sense it may not always be specifically about child processes. I also consider |
|
yes please |
|
Since we’re adding a function for this (yay), we should also guarantee EDIT: |
There was a problem hiding this comment.
s/a nonzero/an arbitrary/, or, perhaps, there’s any reason why calling exit(0) is invalid?
There was a problem hiding this comment.
Ah yes this is definitely meant to allow exit(0), just botched the wording ab it.
|
@nagisa yeah I'm not quite sure how to word the documentation given that |
|
Hmm, there's another major motivation for this that I can think of, which is ending the process without risking unwinding across an FFI boundary, e.g. in a Rust function that has been passed to a C library as a callback. IIRC, unwinding past an FFI boundary is undefined behavior, but we don't have a very solid recommendation for what you should actually do if you need to terminate the process and a foreign function is (or may be) on the stack. About the only thing that you can do to prevent this right now is either call the Edit: I guess that the RFC obliquely mentions this. I guess my point is that this would be a reasonable justification for having an |
This commit is an implementation of [RFC rust-lang#1011][rfc] which adds an `exit` function to the standard library for immediately terminating the current process with a specified exit code. [rfc]: rust-lang/rfcs#1011
|
This was discussed at today's meeting which echoed the support found on this RFC thread. This API is clearly important to provide in some form, and there's little question as to its API. Landing it now will make it possible to yield an exit code without having to stabilize the problematic |
This commit is an implementation of [RFC rust-lang#1011][rfc] which adds an `exit` function to the standard library for immediately terminating the current process with a specified exit code. [rfc]: rust-lang/rfcs#1011 Closes rust-lang#23914
Add a new function to the
std::processmodule to exit the process immediatelywith a specified exit code.
Rendered