Mail Archives: djgpp-workers/2001/09/23/11:59:52
> From: "Tim Van Holder" <tim DOT van DOT holder AT pandora DOT be>
> Date: Sun, 23 Sep 2001 17:20:36 +0200
>
> Then, on a hunch, I added
>
> fflush (debug);
>
> to M4's main(). Lo and behold, it started working.
> The same effect was reached by using
>
> fclose (debug);
>
> So it would seem that the problem is that files attached to FD's
> 3 and 4 do not get closed at the end of the program, resulting in
> empty or incomplete files.
> Still, according to stdiohk.c, all files with fileno > 2 get
> fclose()d by __stdio_cleanup_proc(), and an fprintf() in the
> close helper does show it being called for FDs 0, 2, 4 and 3.
Is it possible that handles 3 and 4 are somehow already closed, or
otherwise invalid, when stdiohk.c gets to fflush and close them? You
should see some kind of failure indications from fflush and/or close
if that's the case.
Another possibility is that some code purges the buffered characters
before stdiohk.c fflushes them. fseek comes to mind (it does fflush
when it purges, but perhaps there's a bug). Looking at the FILE
object of the stream, specifically at f->_ptr and f->_cnt, might tell
something interesting.
- Raw text -