Date: Sun, 23 Nov 1997 19:55:08 +0100 (MET) From: Hans-Bernhard Broeker 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. After looking at the code, I decided to reimplement > the whole stuff, because the original code seems too unsafe for me. Could explain in a bit more detail where, and why it 'seems unsafe'? The current code has been working rather well for quite some time now, so I don't we should dismiss it for a new implementation on such short notice. In other words: if it's not actually *broken*, why replace it completely to fix it? > I added a new feature too, popen-ed but not pclose-d files are > removed when the program exits. That's a good one, I'd say. > 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. Any idea? Not to be sarcastic, but: this is *your* code, so you should know what it's doing, and why, shouldn't you? :-) Anyway, here's a hint: I submitted a bug fix (back in March 1996, then for DJGPP 2.0 beta, I think). The bug was that popen() (and system() as well) lost file handles (i.e. the one used by DOS, and the 'open()' family of functions). The patch mainly consisted in additional calls to 'close(l1->fd);' at two places in the code. Maybe you've hit the same problem? Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.