-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
process: implement raw_handle
getter on Child (#3987)
#3998
Conversation
Another way around this would be to:
|
I think you can obtain a handle right after child creation, and then returned this cached handle in |
Yes, though that will require increasing the structure size on Windows even if the feature isn't used (though this isn't an absolute blocker). Another idea that comes to mind is having flexibility on this with our API stability guarantee. If we chose to go with the fallible API now (i.e. return |
Sounds good, I'll change it to be fallible |
e30a934
to
6172080
Compare
I named it |
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 named it
fn raw_handle(&self) -> Option<RawHandle>
so if the trait is implemented later the name won’t conflict
Hadn't thought about this, its a great idea!
Overall this LGTM, thanks for the quick implementation @passcod ! I'm going to mark this as approved by me and kick off the CI build and we can merge when green
raw_handle
getter on Child (#3987)
Also quick note, now that we're not implementing the |
3bc3a16
to
cff3463
Compare
cff3463
to
cad1184
Compare
Done that and also fixed up the last rustfmt issue |
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.
This seems ok to me as well.
Thanks again @passcod 👍 |
Implementation of #3987. /ping @ipetkov
Notes from discussion in issue:
Child.id()
is not the Windows handle.Thus, it should be possible to implement the
AsRawHandle
trait from std, with the signature:Implementation notes:
AsRawHandle
on bothimp::Child
and the "public": the latter delegates to the former.Child
FusedChild
design: once the process has exited, all that remains isFusedChild::Done(ExitStatus)
— while the underlying stdChild
instance could very well be queried for the raw handle safely, it's gone.Child.as_raw_handle()
panics ifFusedChild
isDone
, orfn as_raw_handle(&self) -> Option<RawHandle>
instead, orFusedChild
works.