English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2007-09-15 (10:42)
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.