Re: [PATCH v2] Ensure standard file descriptors are open on start

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

 



[Moving this subthread back to the autoconf mailing list, it's not
relevant to glibc.]

On Thu, Aug 27, 2020 at 2:22 PM Paul Eggert <eggert@xxxxxxxxxxx> wrote:
> [...] it's better for FD 0 to be write-only and FDs
> 1+2 to be read-only, as that's more likely to prevent buggy programs from
> misbehaving further. For Autoconf, I suggest:
>
>       (exec 3<&0) 2>/dev/null || exec 0>/dev/null
>       (exec 3>&1) 2>/dev/null || exec 1</dev/null
>       (exec 3>&2) || exec 2</dev/null

I tested this.  It makes configure scripts emit floods of "printf:
write error" messages, and exit unsuccessfully despite having run the
entire series of configuration tests, when fd 1 is closed on startup.
This is because configure scripts frequently write to AS_MESSAGE_FD
(which defaults to 1) without bothering to check whether it's writable
first, but they do detect the write error and turn it into a delayed
failure.  (They finish successfully when run with --quiet.)

I could argue that configure _should_ fail when fd 1 is closed on
startup, unless --quiet is on the command line.  However, it should do
so _promptly_, rather than wasting people's time running all the tests
first. Unfortunately I don't see a low-risk way to make that happen.
So I think that for 2.70 we should make fd 0 read-only and 1,2
write-only here, and revisit this afterward -- when we're not in a
release freeze we can think about things like turning on set -e mode.

zw




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux