Skip to content
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

ChildStdin, et cetera should implement AsRawFd/AsRawHandle #22

Open
notgull opened this issue Aug 17, 2022 · 1 comment
Open

ChildStdin, et cetera should implement AsRawFd/AsRawHandle #22

notgull opened this issue Aug 17, 2022 · 1 comment

Comments

@notgull
Copy link
Member

notgull commented Aug 17, 2022

I was going to try to implement I/O safety types on the handles as per sunfishcode/io-lifetimes#38, but then I realized that ChildStdin, ChildStdout and ChildStderr don't implement AsRawFd at all.

I believe that this is due to the fact that Unblock is used to wrap the inner std type, which makes it difficult to access the methods of the inner type. I see three possible ways to resolve this:

  • On Windows, wrap ChildStd* in an Arc that is stored in the structure as well as the Unblock, so that methods on the inner type can be accessed more easily.
  • Make it easier to access the inner file descriptor for Unblock types. We could potentially implement AsRawHandle on Unblock<T: AsRawHandle> that panics if the inner type is not accessible, or maybe some kind of get_ref(&self) -> Option<&T> general purpose method.
  • Implement AsRawFd on unix, since it is easy to get the inner type via async_io::Async, but don't implement the corresponding types on Windows.
@taiki-e
Copy link
Collaborator

taiki-e commented Aug 17, 2022

At this time, I tend to prefer the third (unix only). (Eventually, we probably need to implement them on windows, but there is no need to rush...)

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

No branches or pull requests

2 participants