[comp.unix.wizards] How do you pass file descriptors over IPC?

bin@primate.wisc.edu (Brain in Neutral) (05/03/90)

The BSD IPC documentation makes mention of the possibility of passing
file descriptors between processes using IPC.

How is this done?  (Is this a dumb question?)
- or -
Which BSD programs (if any) do this?  I could then perhaps grab the
source from uunet and examine it.

Paul DuBois
dubois@primate.wisc.edu

brnstnd@stealth.acf.nyu.edu (05/04/90)

In article <2395@uakari.primate.wisc.edu> bin@primate.wisc.edu (Brain in Neutral) writes:
> The BSD IPC documentation makes mention of the possibility of passing
> file descriptors between processes using IPC.

You set up a UNIX-domain socket connection, then use sendmsg() and
recvmsg(). Don't pass any iovs, just a few descriptors. They'll be
renumbered and placed into the receiving array; and they'll be open in
the receiving process.

> Which BSD programs (if any) do this?  I could then perhaps grab the
> source from uunet and examine it.

I don't know of any offhand; it's not a commonly appreciated feature.
I'm using it a bit in some upcoming programs.

---Dan