LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-07-2008, 10:15 AM   #1
nano2
Member
 
Registered: May 2007
Posts: 100

Rep: Reputation: 15
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
 
Old 03-07-2008, 10:26 AM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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.

Last edited by ta0kira; 03-07-2008 at 10:39 AM.
 
Old 03-07-2008, 10:31 AM   #3
nullmind
LQ Newbie
 
Registered: Mar 2008
Posts: 9

Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM
Finding pid of a process opened by "popen" Guttorm Programming 2 03-12-2007 02:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration