delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/11/23/13:56:03

Date: Sun, 23 Nov 1997 19:55:08 +0100 (MET)
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
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.LNX.3.93.971123194500.12501E-100000@acp3bf>
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. 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.

- Raw text -


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