async-process icon indicating copy to clipboard operation
async-process copied to clipboard

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

Open doy opened this issue 3 years ago • 3 comments

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 avatar Dec 23 '21 01:12 doy

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

doy avatar Feb 08 '22 07:02 doy

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 avatar Jul 07 '22 12:07 taiki-e

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) -> ....

taiki-e avatar Jul 07 '22 12:07 taiki-e