apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Travis <jtra...@covalent.net>
Subject Re: Unix missing fd 0..2, Win32 service missing stdin/out/err handles
Date Sun, 14 Apr 2002 21:39:05 GMT
On Sun, Apr 14, 2002 at 10:45:40PM +0200, Sascha Schumann wrote:
> > If a user knows that a third-party library (Oracle, whatever) can
> > provide messages to stderr, and they knowingly close that file
> > descriptor without dup()ing it elsewhere, then that is a bug in
> > their software.
> 
>     Note that the author of the non-apr application does not
>     necessarily must submit to that wisdom.  While you are
>     theoritecally correct, it matters little practically.

The P in APR stands for portable, not 'obscures bugs in your code.'  
This seems to come up every now and then -- APR (poorly) trying to protect
or obscure bugs from programmers -- remember the insanity that occurred
when all that socket inheritance stuff went in?  

> > Having APR open a bunch of file-descriptors so
> > that this fixes a potential problem (IMO bug in their software)
> > is just wasting file descriptors.
> 
>     Not really.  (error handling excluded)
> 
>     do {
>         fd = open("/dev/null", O_RDWR);
>     } while (fd < 3);
>     close(fd);
> 
>     No fd wasted.

I as a daemon, startup, close all my file descriptors, then do an
apr_file_open("/etc/hosts") or some such -- that gives me file
descriptor 3.  That means that I now have 3 fewer file descriptors
to use in my super-duper-file-descriptor-usage application.  Sounds
like wasted descriptors to me.

-- Jon


Mime
View raw message