Subject: Re: bug#8846: coreutils-8.12 on HP-UX 11.31: 3 of 365 tests failed

From: Stefano Lattarini <[email-masked]>
Date: Tue, 14 Jun 2011 00:24:52 +0200

On Monday 13 June 2011, Eric Blake wrote:
>
> Not possible to portably sniff out closed fds; quoting the autoconf manual:
> 
> > Don't rely on duplicating a closed file descriptor to cause an
> > error.  With Solaris @command{/bin/sh}, when the redirection fails, the
> > output goes to the original file descriptor.
> 
Do the shells with the close-on-exec issue also suffer of the issue with
closed fds you've reported?  If not, the following could be enough to
solve our situation without having to change automake:

  if (exec 3>&-; exec 4>&3) >/dev/null 2>&1; then
    # Cannot determine whether a file descriptor is closed, fall back
    # to inferior hack.
    if test 2 -ne "$stderr_fileno_" && test ! -t "$stderr_fileno_"; then
      eval "exec $stderr_fileno_>&2" # Or is `stderr_fileno_=2' enough?
    fi
  else
    if (exec 3>&9) >/dev/null 2>&1; then
      :
    else
      eval "exec $stderr_fileno_>&2" # Or is `stderr_fileno_=2' enough?
    fi
  fi

Regards,
  Stefano