Skip to content

allow waiting on process exit without requiring a mutable borrow and without dropping stdin#19

Open
doy wants to merge 2 commits into
smol-rs:masterfrom
doy:status-drop
Open

allow waiting on process exit without requiring a mutable borrow and without dropping stdin#19
doy wants to merge 2 commits into
smol-rs:masterfrom
doy:status-drop

Conversation

@doy

@doy doy commented Dec 23, 2021

Copy link
Copy Markdown
Contributor

in an async program, it is pretty common to want to be able to wait on something like read.or(write).or(exit), which isn't actually possible with the current api, since calling status closes stdin, and also requires exclusive access to the child. this kind of structure avoids the deadlock issues that wait in the standard library has, and so the decision to close stdin makes a bit less sense.

i added this as a new method to avoid breaking the api, but i would also not be opposed to just changing the semantics of the existing status method. alternate names for status_no_drop would also be good (i couldn't think of anything off the top of my head).

doy added 2 commits December 22, 2021 20:20
it doesn't need exclusive access
this is a much more useful capability for an async process library,
since it is much easier to avoid blocking on this call (since it is a
future)
@doy

doy commented Feb 8, 2022

Copy link
Copy Markdown
Contributor Author

hey, i was just curious what the status of this was - is there anything i can do to help get it merged?

@taiki-e

taiki-e commented Jul 7, 2022

Copy link
Copy Markdown
Collaborator

Thanks for the PR and sorry for the late response. I'm not sure what a good API is to support this (I feel *_no_drop does not sufficiently explain what it does). How does tokio or any other library handle this pattern?

@taiki-e

taiki-e commented Jul 7, 2022

Copy link
Copy Markdown
Collaborator

Also, the signature change of try_status is a breaking change for users who use .as_mut().map(Child::try_status) on Option<Child> or cast Child::try_status as fn(&mut Child) -> ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants