oconnor663 / shared_child.rs

a wrapper around std::process::Child that lets multiple threads wait or kill at once
MIT License
39 stars 7 forks source link

provide access to the underlying child #1

Closed oconnor663 closed 7 years ago

oconnor663 commented 7 years ago

A get_child method could return an Option<&mut Child> or something like that. (Maybe Option<MutexGuard<Child>>?) The contract would be that you get it out if the state is NotWaiting or Waiting, but not if it's Exited, because then the Child struct isn't valid anymore. Note that if the caller swaps out the child, it could cause really weird behavior, if we're still relying on the child's wait method to clean up. Maybe the right thing is to stop using that API entirely, and just use the PID that we stashed at the beginning?

oconnor663 commented 7 years ago

Or, we could provide some other way to get at ChildStdin etc.

Or, we could say that the ChildStdin interface doesn't work super well with sharing, because there's no try_clone or impl Write for &ChildStdin on it. Maybe the answer is that if you want to use those things (or wait_with_output), you need to use os_pipe?

oconnor663 commented 7 years ago

Access to the underlying child is pretty unsafe, which is why we switched from new to spawn. No plans to expose any more of it unless someone needs us to.