Re: Quick close of all the open files.

From: Bernd Petrovitsch
Date: Wed Jun 07 2006 - 04:49:32 EST


On Wed, 2006-06-07 at 06:52 +0530, vamsi krishna wrote:
[...]
> > > I checked as follows I did printf("lowest fd = %d",fileno(tmpfile()));
> > > it prints 3
>
> > Which proves that file descriptor 3 was closed, so tmpfile() was able to
> > open it. This certainly implies that fd 0, 1, 2 (connected to stdin,
> > stdout, and stderr streams of stdio) are still open, contrary to your
> > statement that *all* of them are closed.

And it specifically says absolutely nothing about the file descriptors 4
and larger since open(2) always uses the lowest unused file descriptor.

> I know 0,1,2 are open (I opened it) no need to tell it specifically,
> HOW DO YOU THINK I CAN PRINT SOME THING WITHOUT OPENING THIS
> FILES(stdout,stderr)?

No reason to shout: The trivial solution is to syslog(3) the output like
all of the daemons out there do since ages.

Bernd
--
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services

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