Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Mar 2002 10:06:22 +0200
From:      Oliver Braun <obraun@Informatik.unibw-muenchen.DE>
To:        Kris Kennaway <kris@obsecurity.org>
Cc:        "M. Warner Losh" <imp@village.org>, current@FreeBSD.ORG, peter@FreeBSD.ORG
Subject:   Re: stdout changes break some ports
Message-ID:  <20020331080622.GA95325@nemesis.informatik.unibw-muenchen.de>
In-Reply-To: <20020330224648.A93819@xor.obsecurity.org>
References:  <20020324173513.A75429@xor.obsecurity.org> <20020324.184313.30925676.imp@village.org> <20020324175436.A75804@xor.obsecurity.org> <20020330224648.A93819@xor.obsecurity.org>

next in thread | previous in thread | raw e-mail | index | archive | help
* Kris Kennaway <kris@obsecurity.org> [2002-03-31 08:48]:
> On Sun, Mar 24, 2002 at 05:54:36PM -0800, Kris Kennaway wrote:
> > On Sun, Mar 24, 2002 at 06:43:13PM -0700, M. Warner Losh wrote:
> > 
> > > : David O'Brien committed a workaround to the clog port yesterday to
> > > : move the initializer to main() instead of trying to do it statically.
> > > : 
> > > : Is this something which is supposed to work?
> > > 
> > > No.  This isn't something that is guaranteed to work per the
> > > standards, iirc.  The proper fix is to put the initializer in main.
> > 
> > OK.  Someone needs to go and fix those 84 ports then.
> How does one fix this in a library?  I've been moving the
> initialization to main() for applications.

Unfortunately it is not so straight forward.

IMO, the best solution is to initialise to NULL and test for this when
called and change them to stdin and stdout where necessary.
This is a little overhead but the cleanest way IMO.

I heard of the possibility to do things like

 static FILE*fpout=NULL;
 #define fp (fpout?fpout:stdout)

But I never tested this.

I can help you a little bit changing this in the concerning libraries,
if you want, since this seems to be a lot of work.

Regards,
         Olli
-- 
Department of Computing Science
Federal Armed Forces University Munich
http://ist.unibw-muenchen.de/People/obraun/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020331080622.GA95325>