Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: popen with r+



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:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden
References: 
 >popen with r+ (From: "matt jaffa" <email@hidden>)
 >Re: popen with r+ (From: Ian Lister <email@hidden>)
 >Re: popen with r+ (From: Markus Hitter <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.