passing an open file or socket descriptor

passing an open file or socket descriptor

Post by David Nico » Sat, 01 Dec 2001 07:16:41



is there a way to pass an open fd to another process?

 
 
 

passing an open file or socket descriptor

Post by Oisin McGuinnes » Sun, 02 Dec 2001 07:47:18



> is there a way to pass an open fd to another process?

Read Chapter 15 in the late great W. Richard Stevens' book, "Advanced
Programming in the Unix Environment",
published by Addison Wesley, 1992, ISBN 0-201-56317-7. (Everyone should
own this book.)
He describes the ins and outs of this, with lots of source code. (If you
are doing this for IPC, you
should also consult Volume 2 of the 2nd edition of his "Unix Network
Programming", Prentice Hall 1999, ISBN 0-13-081081-9. It is a great pity
volume 3 did not get done.)

--

Oisin McGuinness

SMBC Capital Markets
277 Park Avenue
New York NY 10172
USA



 
 
 

passing an open file or socket descriptor

Post by Oisin McGuinnes » Sun, 02 Dec 2001 08:38:46




> ?
> ? is there a way to pass an open fd to another process?

> Read Chapter 15 in the late great W. Richard Stevens' book, "Advanced
> Programming in the Unix Environment",
> published by Addison Wesley, 1992, ISBN 0-201-56317-7. (Everyone should
> own this book.)
> He describes the ins and outs of this, with lots of source code.

> --

> Oisin McGuinness

It is sort of obnoxious to follow up on my own reply, but all three of
the techniques
described in section 15.3 of Stevens are supported under Tru64Unix: see
streamio(7) for the SVR4 method
used in Stevens 15.3.1, and sendmsg(2) for support for both BSD4.4 and
BSD4.3 methods
as used in Stevens 15.3.3 and 15.3.2 respectively.

--

Oisin McGuinness

SMBC Capital Markets
277 Park Avenue
New York NY 10172
USA


 
 
 

1. Passing open file descriptors


Use /proc/*/fd/* - you can pass the pid and filedescriptor number as
text, and have the other process simply open the descriptor.  This
assumes that both processes are running as the same user.

This appears to work for network sockets and named pipes as well as
for files, under 1.1.69.

I wouldn't wait for the streams stuff, it could be a while coming.

PS: You're posting to the wrong newsgroup - followups redirected to
col.help.
--

+44 1223 575512    Escoerea on IRC.   http://www.cl.cam.ac.uk/users/iwj10/

2. . sed script dc greg ubben sed stud

3. autoinstall patches and passing file descriptors via sockets

4. Session leader, controlling terminal, process group leader

5. UNIX domain sockets - file descriptor passing

6. Can't get Mosaic invoked.

7. glibc and passing live file descriptors through sockets

8. PCMCIA adapter on LAN

9. Passing file descriptors thru rexec() socket

10. 4.2 inetd passes its last open descriptor to child processes

11. Passing open descriptors between processes

12. Help : Passing Socket Descriptor

13. Help: Passing Socket Descriptor