LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   popen on Linux redhat4.5 doesn't take "rw" ? (https://www.linuxquestions.org/questions/programming-9/popen-on-linux-redhat4-5-doesnt-take-rw-626418/)

nano2 03-07-2008 10:15 AM

popen on Linux redhat4.5 doesn't take "rw" ?
 
Hi ,

I have been trying to use popen to take "rw" mode , but it fails I get "Invalid argument" . It will only take either "r" or "w" . However I have used both "rw" on Solaris and hp compilers Why is gcc3.4.6 on Linux different ...
Is there any way in which I can use "rw" with popen ...

Thanks

ta0kira 03-07-2008 10:26 AM

popen gives you one or the other: not both. That's because standard POSIX pipes are half-duplex only. You might consider socketpair, fork, dup2, fdopen, and system. "rw" is probably just a Solaris extension, but I don't think it's standard.
ta0kira

PS I'm sure it wouldn't be much trouble to hack libc and steal the popen function to make your own full-duplex version. Just copy the function, name it something else, add the "rw" argument, use socketpair instead of pipe when "rw" is used, then dup2 to both standard input and output instead of just one. I'll take a look later and see if I can come up with an example.

nullmind 03-07-2008 10:31 AM

Not sure how "offical" this is, but appears that "r" and "w" are the only supported arguments:

http://opengroup.org/onlinepubs/0079...xsh/popen.html

This also seems to show that linux only wants those arguments:

http://linux.die.net/man/3/popen

CHeers,
Kris


All times are GMT -5. The time now is 11:51 PM.