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

Should IO::Handle instances be possible to construct using file descriptors? #73

Open
Kaiepi opened this issue Jul 20, 2019 · 1 comment
Assignees
Labels
rakudo Big changes to Rakudo

Comments

@Kaiepi
Copy link

Kaiepi commented Jul 20, 2019

I was working on a module that abstracts out the annoying parts of dealing with PTYs (namely creating them and spawning child processes using them) when I found that it was impossible to write as a subclass of IO::Handle because creating instances of IO::Handle using a file descriptor isn't possible to do. Since IO::Handle's only way of opening files currently takes a path, the only way IO::Handle could be used with PTYs is to get the file name of the master file descriptor and use that, but how this can be done and whether or not it's even possible varies from platform to platform, making it difficult to write portably. While I can create an IO::Handle instance for the slave's file descriptor (since ptsname allows you to get its path), I can't duplicate it and use the new file descriptor with another IO::Handle instance so it can be bound to a Proc::Async instance's stdin/stdout/stderr because, again, IO::Handle instances can't be created using file descriptors.

If wrapping IO::Handle like this with NativeCall is sane, since I imagine this isn't the only case where one would want to be able do this, should it be possible to create IO::Handle instances using file descriptors?

@AlexDaniel AlexDaniel added language Changes to the Raku Programming Language rakudo Big changes to Rakudo and removed language Changes to the Raku Programming Language labels Jul 20, 2019
@jnthn
Copy link
Contributor

jnthn commented Jul 20, 2019

should it be possible to create IO::Handle instances using file descriptors

Yes.

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

No branches or pull requests

4 participants