Re: popen with r+
Re: popen with r+
- Subject: Re: popen with r+
- From: Ian Lister <email@hidden>
- Date: Wed, 21 Jun 2006 17:55:42 +1000 (EST)
On Wed, 21 Jun 2006, Markus Hitter wrote:
Am 21.06.2006 um 01:10 schrieb Ian Lister:
pipe() gives you a single, unidirectional pipe.
From popen()'s man page in Tiger:
"Since popen() is now implemented using a bidirectional pipe, the type
argument may request a bidirectional data flow."
Note that my comment was about pipe() and the man page you quoted was for
popen(). Perhaps you realised that but I'll point it out for the casual
observer regardless.
My point was that you're not going to be able to implement a bidirectional
popen() with a single unidirectional pipe. In fact, calling pipe() twice
doesn't help because you need to wrap them in a single FILE *, so
socketpair() and fdopen() is the way to go.
Having had a cursory scan of Libc/gen/popen.c in Jaguar and Panther it
seems that the Panther implementation was blindly copied from FreeBSD,
which has bidirectional pipes whereas Darwin doesn't (based on the man
page), and the Jaguar implementation does call socketpair() but then
overwrites the file descriptors by calling pipe() anyway (a silly bug). I
have no idea what micro versions of the OS the source I was looking at
corresponded to as it was just whatever was lying on my disk.
Cheers,
Ian
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden