Date: Thu, 12 Oct 2000 19:29:12 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: Jeffrey_Krupp AT May-Co DOT com Message-Id: <2110-Thu12Oct2000192912+0300-eliz@is.elta.co.il> X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.5h CC: djgpp AT delorie DOT com In-reply-to: (Jeffrey_Krupp AT May-Co DOT com) Subject: Re: zero file descriptors References: Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: Jeffrey_Krupp AT May-Co DOT com > Date: Thu, 12 Oct 2000 11:41:50 -0400 > > I am having a problem with fopen where it opens a file (returns a valid > file pointer), but then its file handle is zero. What does "fileno(stdin)" yield when you fopen returns such a FILE object? > Is this a compiler bug Definitely not a compiler bug. It might be a library bug (what version of DJGPP are you using, btw?), but that's unlikely. Handle zero should be connected to the standard input before the program starts up (it is done by the OS, because the program inherits the first 5 handles of its parent, the shell). If the stdin handle is not zero, it is possible that fopen could reuse handle 0 for another file, but then I don't understand why can't you fseek. In usual circumstances, handle 0 can only be allocated for normal disk files if you "fclose(stdin)" or "close(0)" before that. It would help if you could post a minimal complete program that exhibits this problem on your system. > I have also tried the same program in MS-DOS 5.0 - same results. I work a lot on MS-DOS 5.0, and I have never seen such a problem.