[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fflush & close behavior not well-defined

From: Manuel Collado
Subject: Re: fflush & close behavior not well-defined
Date: Mon, 14 Sep 2020 17:27:13 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

El 14/09/2020 a las 15:07, Andrew J. Schorr escribió:

On Sun, Sep 13, 2020 at 11:50:17PM -0600, arnold@skeeve.com wrote:
Thanks for the report. Gawk's close already takes an optional second
argument ("from" or "to") for closing one end of a two-way pipe.

True, but if you look at the code in io.c:do_close, you'll see that the from/to
"how" argument does not come into play until after the open file is identified
by scanning the red_head list. So the presence of that argument does not limit
the search to the subset of open pipes. It merely triggers a warning from
io.c:close_redir if used with a file that's not a pipe. So in the case of
close, the fix would require up to 3 arguments:
    close(file, [, filetype [, how]])
(with the code being smart enough to detect when "how" is located in the
2nd position).

Another possibility would be to add two specific close() wrappers, say

close_pipe(pipe, how)

To be used if it is necessary to disambiguate.

Just an idea.

Manuel Collado - http://mcollado.z15.es

reply via email to

[Prev in Thread] Current Thread [Next in Thread]