delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/11/24/06:03:44

Date: Mon, 24 Nov 1997 13:02:53 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: molnarl AT cdata DOT tvnet DOT hu
cc: djgpp-workers AT delorie DOT com
Subject: Re: popen/pclose update
In-Reply-To: <Pine.SOL.3.95.971121135940.1111A-100000@dumballah.tvnet.hu>
Message-ID: <Pine.SUN.3.91.971124130225.23713B-100000@is>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019