Expand documentation of process::exit and exec#38518
Conversation
|
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
|
@bors: delegate=kmcallister r? @kmcallister |
|
✌️ @keeganmacallister can now approve this pull request |
|
✌️ @kmcallister can now approve this pull request |
src/libstd/process.rs
Outdated
There was a problem hiding this comment.
What do you think about this as an example:
use std::io::{self, Write};
use std::process;
fn run_app() -> Result<(), ()> {
// Your application logic here
Ok(())
}
fn main() {
process::exit(match run_app() {
Ok(_) => 0,
Err(_) => 1,
});
}There was a problem hiding this comment.
I personally prefer to not include an import for only one use of a function. I incorporated some of the other changes.
There was a problem hiding this comment.
Why are you printing the error if the error type is ()?
There was a problem hiding this comment.
I suppose I can see why, but it does seem unrelated to the point of this example. Not a big deal.
src/libstd/sys/unix/ext/process.rs
Outdated
There was a problem hiding this comment.
Would it be more accurate to replace "any other thread's" with "child thread's"?
There was a problem hiding this comment.
No. “Child thread” makes sense in relation to “main thread”, but you can call process::exit on any thread you want.
src/libstd/sys/unix/ext/process.rs
Outdated
There was a problem hiding this comment.
Is this platform specific behavior? I'm not familiar with how all the platforms handle execvp
There was a problem hiding this comment.
It is not. We always try our best to set CLOEXEC on all filedescriptors in the standard library and the behaviour of execvp wrt CLOEXEC fds is documented in posix: http://pubs.opengroup.org/onlinepubs/9699919799/functions/execvp.html
src/libstd/sys/unix/ext/process.rs
Outdated
There was a problem hiding this comment.
Nit: that the execvp syscall
src/libstd/process.rs
Outdated
There was a problem hiding this comment.
Nit: compute the exit code
|
Ping? |
src/libstd/process.rs
Outdated
There was a problem hiding this comment.
I think the documentation uses American English, so this should be "behavior"
Show a conventional way to use process::exit when destructors are considered important and also mention that the same caveats wrt destructors apply to exec as well.
|
@bors: r+ |
|
📌 Commit c2eab73 has been approved by |
|
@bors rollup |
Expand documentation of process::exit and exec Show a conventional way to use process::exit when destructors are considered important and also mention that the same caveats wrt destructors apply to exec as well.
Expand documentation of process::exit and exec Show a conventional way to use process::exit when destructors are considered important and also mention that the same caveats wrt destructors apply to exec as well.
Show a conventional way to use process::exit when destructors are considered important and also
mention that the same caveats wrt destructors apply to exec as well.