Version française
Home     About     Download     Resources     Contact us    
Browse thread
Closing all open file descriptors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Oliver Bandel <oliver@f...>
Subject: Re: [Caml-list] Closing all open file descriptors
Zitat von Erik de Castro Lopo <mle+ocaml@mega-nerd.com>:

> Oliver Bandel wrote:
>
> > If you think you need all this for your daemon,
> > I ask: why do you think you need it? If you write it, you have
> > full control over all files you open
>
> No, thats not right. I can write a program, that opens a bunch
> of file descriptors, and then exec his program and his program
> will inherit all open file descritors.

Yes, that's correct.
But you (as the programmer) have the control (by design)
about how to handle that case.

If you have all your open descriptors in a list,
you can close them after a fork.

In C, with fcntl, there is a possibility to close files
on an exec automatically with the close-on-exec flag.

Ciao,
   Oliver