Re: FD_CLFORK or equivalent?

Alan Cox (alan@lxorguk.ukuu.org.uk)
Tue, 4 May 1999 20:49:14 +0100 (BST)


Argh wrong button. Remind me not to use vi

To continue

> Is there an existing Linux/Unix mechanism to force fds closed
> on fork() that I am unaware of?

They exist only for exec - since within just a fork() the situation
is under your control. It is your fault if you forget to close() it - the
kernel isnt there to baby you - and if you want it to you can write a nice
fork wrapper that asks the library to close handles it is using.

> If not, before I hack one in as a private kernel patch, is
> there any reason to add such a mechanism, perhaps a FD_CLOFORK
> flag, and does anybody have suggestions on where to start?

FD_CLOFORK is the logical way to do it so that it matches FD_CLOEXEC. Think
hard about the semantics for threaded applications where they share the
same file handles when doing this.

Alan

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/