Passing open file descriptor to the exec'ed process

Thomas Olano olano at currituck.cs.unc.edu
Fri Oct 19 03:04:02 AEST 1990


In article <34954 at cup.portal.com> DeadHead at cup.portal.com (Bruce M Ong) writes:
...
>	I have a parent process that makes a socket connection with a remote
>server. And depending on a server reply message type, I want the parent
>process to exec another program (the parent process will go away, with
>the new program replacing it). However, i dont want to close the connection
>and open the connection again from the new program - I want the new program
>to inherite the open socket descriptor and continue to talk to the server,


When I did something similar, I passed the open socket descriptor to the 
child using environment variables.  This may not be the "easiest" or "best"
way to do it, but hey, it worked!  Essentially the parent set an environment
variable with putenv() and the child read it with getenv().  Perhaps a more
elegant method would be to pass the descriptor as an argument in the exec
call.  The default is for files and sockets to remain open over and exec so
everything should be happy.

Marc Olano
olano at cs.unc.edu
no cute signature



More information about the Comp.unix.programmer mailing list