GNU bug report logs - #8846
coreutils-8.12 on HP-UX 11.31: 3 of 365 tests failed

Previous Next

Package: coreutils;

Reported by: Bruno Haible <bruno <at> clisp.org>

Date: Mon, 13 Jun 2011 09:17:01 UTC

Severity: normal

Tags: moreinfo

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #74 received at 8846 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Jim Meyering <jim <at> meyering.net>
Cc: stefano.lattarini <at> gmail.com, "bug-autoconf <at> gnu.org" <bug-autoconf <at> gnu.org>,
	8846 <at> debbugs.gnu.org, Bruno Haible <bruno <at> clisp.org>
Subject: Re: bug#8846: coreutils-8.12 on HP-UX 11.31: 3 of 365 tests failed
Date: Mon, 13 Jun 2011 09:47:17 -0600
[Message part 1 (text/plain, inline)]
On 06/13/2011 09:37 AM, Jim Meyering wrote:
>> But I think the reason that it invokes a problem is not because of the
>> 1>&$e construct, but because HP-UX opens secondary file descriptors as
>> cloexec or otherwise closing them at some point, so the '/bin/sh k'
>> child process is not inheriting fd 9 from the parent process.
> 
> Ah ha!
> That sounds like a syscall that needs to be gnulib-replaced in bash/zsh.
> Of course, first we'd need to gnulib-enable a shell.

Yep, I've confirmed that both HP-UX and Solaris 10 ksh use CLOEXEC fds
for intermediate fd values created by exec; that POSIX permits (but
fortunately does not require) this behavior, and that autoconf already
documents the pitfall of expecting fds > 2 to be preserved into child
processes:

http://www.gnu.org/software/autoconf/manual/autoconf.html#File-Descriptors

> Don't rely on open file descriptors being open in child processes. In ksh, file descriptors above 2 which are opened using ‘exec n>file’ are closed by a subsequent ‘exec’ (such as that involved in the fork-and-exec which runs a program or script). Thus, using sh, we have:
> 
>      $ cat ./descrips
>      #!/bin/sh -
>      echo hello >&5
>      $ exec 5>t
>      $ ./descrips
>      $ cat t
>      hello
>      $
> 
> But using ksh:
> 
>      $ exec 5>t
>      $ ./descrips
>      hello
>      $ cat t
>      $

On Solaris 10, truss shows this for 'exec 9>&2':

dup(2)                                          = 3
close(9)                                        Err#9 EBADF
fcntl(3, F_DUPFD, 0x00000009)                   = 9
close(3)                                        = 0
fcntl(9, F_SETFD, 0x00000001)                   = 0

>   tusc (11+, freeware)

Likewise on HP-UX 11.31, tusc shows:

dup(2) ................................................... = 3
close(9) ................................................. ERR#9 EBADF
fcntl(3, F_DUPFD, 9) ..................................... = 9
close(3) ................................................. = 0
fcntl(9, F_SETFD, 1) ..................................... = 0

About the only thing I can think of is to pass the details about the
desired redirection as a command-line or env-var setting, to be done by
the script itself, rather than relying on the parent shell (the one in
make) being able to do a redirection that persists into the child (the
one sourcing init.sh).

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 13 years and 347 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.