Mail Archives: djgpp-workers/1997/11/24/06:03:44
On Fri, 21 Nov 1997 molnarl AT cdata DOT tvnet DOT hu wrote:
> It's time to update popen()/pclose() again :-) I've found a bug in
> pclose: if you write something like this: pclose (stdin), you will
> get a SIGSEGV.
This shouldn't require more than a simple change. No need to rewrite
everything, IMHO.
What else is wrong in the original version?
> However I have a question: if you look at the line with '!!!' in
> pclose, could you tell me why I have to include that line? I don't
> understand why fflush is not enough.
Not enough for what? What exactly doesn't work when you omit that
line?
If the problem is that some of the output is not written to the
temporary file, then the reason is that `fflush' only flushes the
buffered output which is kept in libc. It does not flush DOS internal
buffers. You need to call `fsync' or `close' to make all the data
written to the file. Since there's nothing else to be written to the
temporary file, closing it seems like a good idea, and that's what the
original code did as well. What's wrong with that?
- Raw text -