struct msghdr, passing fds between processes

Christopher JS Vance cjsv at sserve.cc.adfa.oz.au
Mon Apr 22 22:32:48 AEST 1991


I note that a BSD struct msghdr (used with sendmsg and recvmsg) allows the
passing of `access rights'.  I seem to remember someone indicating that this
meant open file descriptors, sort of like a call on dup, except to a different
process.

Could someone who knows please point me to some documentation of this feature,
or at least let me know what kinds of stream these can be passed over.  I assume
that the numbers change on the wire and come out as open fds at the other end.

I guess that the stream must probably be a UNIX domain socket or pipe.  Or am
I barking up the wrong tree?

What I'd like to do is start up a process which has access to my login terminal,
have it open a socket-based connection to a server process, and have it pass
access to my login terminal to the server process.

(Subsidiary question - if I can do this, and my server process had no
controlling terminal, does it suddenly inherit one?)

What colour dragons be here?  (i.e., what do I need to be wary of?)

A bit of working code would be a bonus.  If your reference is the BSD book by
Leffler et al., I can borrow a copy, but won't bother unless it helps.  I had
a copy of the Advanced IPC document, but I don't seem to remember seeing it
there, and the person who has my copy hasn't returned it.  I can get it back,
though, if it's worth it.

-- 
Christopher



More information about the Comp.unix.internals mailing list