From: Caolan McNamara (cmc at domain stardivision.de)
Date: Tue 18 Jul 2000 - 16:33:00 IST
Funny how you get blind spots about various things, was discussing
file descriptors and have been assuming for ages that a newly execed
program got a completely new set of such resources. But on reading the
sun man page I was enlightened.
After a fork both parent and child have the same fds, after an exec
the new process *still* has the same open fds (as long as fcntl with ,
FD_CLOEXEC to close them on exec isnt set). Enter crash tolerant stuff...
sockets to server, server crashes, its segv handler writes out the fd
numbers to disk or passes them on command line, and forks and execs a new
instance of itself whereupon the new one just uses the preexisting fd
numbers and keeps on trucking. All the dodgy original image is jettisoned
and you move on with a virgin copy but your connections remain open,
amusing I thought. I thought I'd share.
C.
p.s. titchy demo at
http://www.csn.ul.ie/~caolan/publink/ForkExec/CunningForkExecSegvHandler.c
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:54 GMT