Date: Fri, 3 May 1996 11:36:26 -0700 (MST) From: Terry Lambert <terry@lambert.org> To: rpt@miles.sso.loral.com (Richard Toren) Cc: freebsd-hackers@FreeBSD.org Subject: Re: stdio problem Message-ID: <199605031836.LAA14591@phaeton.artisoft.com> In-Reply-To: <Pine.SUN.3.91.960503073715.11811A-100000@miles> from "Richard Toren" at May 3, 96 07:48:50 am
next in thread | previous in thread | raw e-mail | index | archive | help
> The "assumption" that 'fd 0 == stdin at entry to main()' is no longer > valid! > > In the classes I teach here at work, this is one of the examples I use > about how old shortcuts/standards make for non-portable code and insidious > bugs. > > I learned this from first-hand experience where fileno(stdin) did not > equal 0 but rather 1. And this was a program started from the standard > csh command line. > > This happens when a C++ static initializer procedure opens a file before > the crt0.o (or it's C++ equivelant) has yet run. In this case, > std{in,out,err} are fds n+0, n+1, n+2. Hmmmm... I've got to argue that this could only result from bad code for dealing with static initializers. What about a static initializer that operates on stdio? Is this now deemed illegal? fd's 0, 1, and 2 come from the exec, not from the crt0.o, in any case. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605031836.LAA14591>