So my question is this:
Given stdin (read only) and stdout (write only) [*] is there a way to create a single read/write filehandle that reads from stdin and writes to stdout? And tie() doesn't count as I need this to pass to poll().
[*] Unless you're djb, but that's just freaky
er, (Score:2)
This would be without using Inline::C to compile a new kernel module, I take it?
a.k.a. no idea, and I'm not convinced that it's possible. (so someone prove me wrong, please)
fd 0 already does this for ttys (Score:1)
However, if you can't make that assumption -- ie if fd 0/1 may have been redirected to a non-tty source/sink, no, I don't think it's possible.
Re:fd 0 already does this for ttys (Score:2)
socketpair(), possibly (Score:2)
I think that some systems make socketpair(2) [freebsd.org] bidirectional fd's. It appears that way on my FreeBSD box, but I don't know about others. Hmmm, even pipe(2) [freebsd.org] appears bidirectional on FreeBSD actually.
-Dom
Re: (Score:1)
As near as I can tell, yes, but only if STDIN and STDOUT are opened on the same thing (ie the only difference between them is the mode). Don't ask me how to get such a filehandle.
What do you need this for?
Re: (Score:2)
In fork/inetd mode the app still uses poll() internally (for various reasons) so it'd be nice to be able to just use the same code for each. Instead in inetd mode I have to pull a line off the read handle, and ask the write handle to process it and create the output.
This is all rather hard to explain in english
would this do? (Score:1)
Re:would this do? (Score:2)
Matt.
Re:would this do? (Score:1)
Re:would this do? (Score:2)
Of course I've now spent a few days building a work around