Re: Piping capability communication, data vs. descriptor capability strengths
Trey Boudreau <trey-gaUk1npE+QlWk0Htik3J/[email protected]>
| Newsgroups | gmane.comp.capabilities.general,gmane.comp.lang.e.general |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Feb 27, 2009 at 10:41:27AM +0000, [email protected] wrote: > > Jed Donnelley <capability-iCFHVraI1K1Wk0Htik3J/[email protected]> writes > > > Even in Unix I've heard that open file descriptors can be sent > > through a pipe. If that's so, what's the syntax (e.g. as above) look > > like? How are the descriptors sent and received specified (by the > > sender on sending and by the OS on receiving to the receiver)? > > You can send descriptors as seen in > "Advanced Programming in the Unix Environment" section 15.3. > which uses ioctl() with I_SENDFD . > http://opengroup.org/onlinepubs/007908799/xsh/ioctl.html > > The sender already has the descriptor it's sending and refers to it > by number (small integer) and ioctl() produces from that a value > related to kernel tables that will be meaningful to an ioctl() with > I_REVCFD in the receiving program. > > I've never done that - normally when I set up one pipe between a pair > of processes I can set up two. You'd rarely pass a descriptor to a > program you call directly and I don't think there's any shell pipeline > syntax to do so. > "call directly" usually means fork/exec, in which case the child inherits all of your existing file descriptors so you don't need to send them. Sending file descriptors via ioctl() works regardless of the relationship between the two processes, IIRC. -- Trey