Re: closing extra fd's in gnome_execute_*
- From: Elliot Lee <sopwith redhat com>
- To: Jeff Garzik <jgarzik pobox com>
- cc: Manish Vachharajani <mvachhar vger rutgers edu>, gnome-list gnome org
- Subject: Re: closing extra fd's in gnome_execute_*
- Date: Mon, 11 Jan 1999 12:46:30 -0500 (EST)
On Mon, 11 Jan 1999, Jeff Garzik wrote:
> On Mon, 11 Jan 1999, Manish Vachharajani wrote:
> > Consider this. I am running program foo. foo opens a 30 megabyte file.
> > While the file is open it runs gnome_execute_async, say for the
> > help-browser or something. Now my disk runs out of space, so I rm the 30
> > meg file after quitting application foo. Unfortunately, I won't regain
> > that space until I close the help-browser. If foo happens to start many
> > programs, I have to quit them all before the space will be freed. This
> > will definitely bite us in the ass as well. We really should close the
> > fd's unless we want other behavior.
>
> Some programs even use magic fd numbers to facilitate fd passing between
> programs aware of these magic numbers.
>
> The default should be to close the fds; to do otherwise would violate
> the Principle of Least Surprise...
You can't possibly close all the fd's without a pretty drastic performance
hit, especially since the kernel is getting large FD set support (4
billion FD's IIRC).
Programs that are broken need to be fixed, instead of putting tons of
workarounds into other programs that use the broken ones. It's nice to
talk about how you need it to work now with existing programs etc. etc.,
but adding this into gnome-libs is short term "fix my particular problem
right now" myopia, without looking at the long term, where all these
broken programs will either get fixed or stop being used, and people will
regret adding the behaviour that must remain for posterity.
The right way to get rid of extra fd's passed to child processes is to set
the FD_CLOEXEC flag on the fd in the application, so that it doesn't stay
open in the executed program. ORBit already does this for its fd's, and it
should be done for all fd's except pipes.
The principle of least surprise implies (to me) doing nothing unless it is
specifically asked for. If you want to put your "close fd's 0-N, and I'll
pretend they all got closed" hack in libgnome, it would be better to add
gnome_execute_*_closing_fds() variants, rather than changing the default.
The default routines need to fit as wide a variety of cases as possible,
with convenience wrappers done as special-case versions of the default
routines.
The funny thing is I don't have any problems at all with bash and
high-numbered fd's.
-- Elliot
"In film you will find four basic story lines. Man versus man, man
versus nature, nature versus nature, and dog versus vampire."
- Steven Spielberg
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]