-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Expand documentation of process::exit and exec #38518
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,10 +67,20 @@ pub trait CommandExt { | |
/// an error indicating why the exec (or another part of the setup of the | ||
/// `Command`) failed. | ||
/// | ||
/// `exec` not returning has the same implications as calling | ||
/// [`process::exit`] – no destructors on the current stack or any other | ||
/// thread’s stack will be run. Therefore, it is recommended to only call | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be more accurate to replace "any other thread's" with "child thread's"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. “Child thread” makes sense in relation to “main thread”, but you can call process::exit on any thread you want. |
||
/// `exec` at a point where it is fine to not run any destructors. Note, | ||
/// that the `execvp` syscall independently guarantees that all memory is | ||
/// freed and all file descriptors with the `CLOEXEC` option (set by default | ||
/// on all file descriptors opened by the standard library) are closed. | ||
/// | ||
/// This function, unlike `spawn`, will **not** `fork` the process to create | ||
/// a new child. Like spawn, however, the default behavior for the stdio | ||
/// descriptors will be to inherited from the current process. | ||
/// | ||
/// [`process::exit`]: ../../../process/fn.exit.html | ||
/// | ||
/// # Notes | ||
/// | ||
/// The process may be in a "broken state" if this function returns in | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about this as an example:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you printing the error if the error type is
()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose I can see why, but it does seem unrelated to the point of this example. Not a big deal.