Skip to content

Add set_status for std::process::Child #69843

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

Closed
wants to merge 4 commits into from
Closed

Add set_status for std::process::Child #69843

wants to merge 4 commits into from

Conversation

dylni
Copy link
Contributor

@dylni dylni commented Mar 9, 2020

Closes #39188

Are tests other than the doctest needed? Any good test would need to be very platform-specific.

I also removed ExitStatus::new, since it was only used for some platforms and could be replaced with constructing the struct directly.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @withoutboats (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 9, 2020
@dylni
Copy link
Contributor Author

dylni commented Mar 10, 2020

Reassigning to another libs member. I don't think @withoutboats has been reviewing recently.

r? @sfackler

/// [`wait`]: #method.wait
/// [`wait_with_output`]: #method.wait_with_output
#[stable(feature = "child_set_status", since = "1.44.0")]
pub unsafe fn set_status(&mut self, status: ExitStatus) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what way can calling this method incorrectly cause memory unsafety?

Copy link
Contributor Author

@dylni dylni Mar 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original reasoning was that kill would be unexpectedly affected, and there could be other internal uses by Child in the future. However, thinking through it again, it does make sense to remove the unsafe.

@sfackler
Copy link
Member

I'm somewhat worried that this opens too many boxes about the internal representation of Child - thoughts @rust-lang/libs?

@dylni
Copy link
Contributor Author

dylni commented Mar 14, 2020

If there's a warning that setting it to an inaccurate exit status results in undefined behavior, there shouldn't be a problem. It would require unsafe code to get the exit status externally anyway.

However, after updating the wait implementation in my crate, I actually no longer need to call this function. So, I am not entirely opposed to delaying it if there are objections.

@sfackler
Copy link
Member

Ah cool yeah, if your code isn't going to be depending on the functionality, then I think it makes sense to close this for now then.

@sfackler sfackler closed this Mar 17, 2020
@dylni
Copy link
Contributor Author

dylni commented Mar 18, 2020

That works. Thanks for the review anyway!

@dylni dylni deleted the issue-39188 branch May 16, 2020 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow process::Child to be used with external calls to waitpid
4 participants