[ILUG] amusing hack, keep socket connection open despite segv

Dave Airlie David.Airlie at ul.ie
Tue Jul 18 23:41:08 IST 2000


Now I know what will happen when SO 5.3 comes out ...

Dave.

On Tue, 18 Jul 2000, Caolan McNamara wrote:

> 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
> 
> 
> 

-- 
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied at skynet.ie
pam_smb / Linux DecStation / Linux VAX / ILUG person






More information about the ILUG mailing list