Date: Mon, 24 Nov 1997 13:02:53 +0200 (IST) From: Eli Zaretskii To: molnarl AT cdata DOT tvnet DOT hu cc: djgpp-workers AT delorie DOT com Subject: Re: popen/pclose update In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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?