bug-coreutils
[Top][All Lists]
Advanced

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

bug#16940: [PATCH] tests: Do not access /dev/tty if it does not exist


From: Pádraig Brady
Subject: bug#16940: [PATCH] tests: Do not access /dev/tty if it does not exist
Date: Wed, 05 Mar 2014 15:21:37 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 03/05/2014 09:17 AM, Bernhard Voelker wrote:
> On 03/05/2014 05:20 AM, Pádraig Brady wrote:
>>    if test -w /dev/full && test -c /dev/full &&
>>       test -w /dev/tty && test -c /dev/tty; then
> 
> This looks right.
> However, I'm wondering why the 'test -t 1' right after
> the exec redirection didn't already catch this:

Good point.

>   if test -w /dev/full && test -c /dev/full; then
>   (
>     exec >/dev/tty
>     test -t 1 || exit 0
>     nohup echo hi 2> /dev/full
>     test $? = 125 || fail=1
>     test -f nohup.out || fail=1
>     test -s nohup.out && fail=1
>     rm -f nohup.out
>     exit $fail
>   ) || fail=1
>   fi
> 
> Does someone have a test log file with the failure?

Ondřej Vašík ran the rawhide build again producing:

  ./tests/misc/nohup.sh: line 66: /dev/tty: No such device or address
  + fail=1

So exec >/dev/tty is throwing ENXIO and exiting the subshell.
ENXIO is fine and corresponds to the process not having a controlling tty.

I guessed the change here is with the newly released bash 4.3
which is exiting the subshell immediately in this case, and confirmed
the following fails:

  setsid make SHELL=~/bash-4.3/bash TESTS=tests/misc/nohup.sh SUBDIRS=. check

Now reducing the case and comparing different shells we get:

  $ setsid bash --posix -c 'echo $BASH_VERSION; (exec >/dev/tty; exit 0) || 
echo failed_early'
  4.2.45(1)-release
  bash: /dev/tty: No such device or address

  $ setsid ./bash --posix -c 'echo $BASH_VERSION; (exec >/dev/tty; exit 0) || 
echo failed_early'
  4.3.0(1)-release
  ./bash: /dev/tty: No such device or address
  failed_early

  $ setsid ksh -c '(exec >/dev/tty; exit 0) || echo failed_early'
  $ ksh: /dev/tty: cannot create [No such device or address]
  failed_early

  $ setsid dash -c '(exec >/dev/tty; exit 0) || echo failed_early'
  dash: 1: cannot create /dev/tty: No such device or address
  failed_early

So rather than newer bash being the difference here,
it's the older bash that is the outlier.
So we should adjust the test case to handle all shells.
Proposed patch attached.

thanks,
Pádraig.

Attachment: nohup-bash-4.3.patch
Description: Text Data


reply via email to

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