Subject: Re: Warning message: Why do I care?
To: Steven M. Bellovin <firstname.lastname@example.org>
From: John Franklin <email@example.com>
Date: 08/01/2002 14:26:27
On Thu, Aug 01, 2002 at 02:07:40PM -0400, ww@STYX.ORG wrote:
> On Thu, Aug 01, 2002 at 02:02:34PM -0400, Steven M. Bellovin wrote:
> > In message <20020801135402.K2158@styx.org>, firstname.lastname@example.org writes:
> > >On Thu, Aug 01, 2002 at 12:34:07PM -0400, John Franklin wrote:
> > >>
> > >> I disagree. Too much software treats fd 0-2 as sacred. I don't think
> > >> that open(2) should ever return a fd below 3. I don't belive this would
> > >> break anything.
> > >
> > >how would you redirect output to a file then? usually this
> > >is implemented with something like
> > >
> > > close(1);
> > > fd = open("somefile", O_WRONLY);
> > >
> > You could use dup2(). But I suspect there's a lot of code around that
> > does it your way.
> sure. s/usually/often/. point is, it would definitely break things.
Ok. It would break things. But the fix would be trivial. dup2(2) is
POSIX, so it's resonable to expect it on most systems, and it's an
explicit way of achieving the desired effect whereas the above code
relies on a behavioral characteristic of open(2). Not to mention a
multi-threaded program could find itself with a race condition if it
Is this behavior of open(2) mandated by POSIX or some other hard
ICBM: 35°43'56"N 78°53'27"W