Mail Archives: djgpp/2000/10/12/13:29:35
> 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.
- Raw text -