autoconf-patches
[Top][All Lists]
Advanced

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

Re: RFC PATCH 1/2] AS_INIT: try to ensure fds 0, 1, 2 are open


From: Paul Eggert
Subject: Re: RFC PATCH 1/2] AS_INIT: try to ensure fds 0, 1, 2 are open
Date: Thu, 27 Aug 2020 11:09:41 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

+  if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
+  if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
+  if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi

This is all _AS_ENSURE_STANDARD_FDS needs to do; none of the other stuff is needed and I suggest omitting it as a maintenance time-sink.

POSIX programs and utilities merely need file descriptors 0, 1, and 2 to be open; it doesn't matter whether they're open for read or for write. The point is that an ordinary 'open' syscall should never return FDs 0 thru 2; not that 'read' from 0 or 'write' to 1 or 2 must succeed (there's never any guarantee of that).



reply via email to

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