On 09/11/15 16:58, Pádraig Brady wrote: > On 09/11/15 16:48, Jim Meyering wrote: >> On Mon, Nov 9, 2015 at 8:07 AM, Pádraig Brady <[email protected]> wrote: >>> On 09/11/15 16:02, Bernhard Voelker wrote: >>>> On 11/09/2015 04:27 PM, Pádraig Brady wrote: >>>>> I see on most GNU/Linux distros that kill(1) is >>>>> provided by the shell or util-linux. >>>>> Should we just remove it from coreutils? >>>> >>>> What about non-Linux systems, i.e., where util-linux is not >>>> available? I personally don't have such a system, but I think >>>> GNU software should not forget about such platforms. >>> >>> Absolutely. Though in this case the shells cater >>> for kill(1), or the platform already provides it. >> >> Note that POSIX requires an 'exec'able kill program. >> I.e., the shell-provided one is insufficient when you want to >> invoke it via a program like xargs. > > OK I'll assume for now that platforms > might not have a separate kill program, > and move it to disabled_by_default_progs.
Attached.
>From eefff4ceedf16994ce860af4d98d60726952e38d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]> Date: Mon, 9 Nov 2015 18:50:21 +0000 Subject: [PATCH] kill: don't build by default Since kill(1) is usually provided by the shell and the system, don't build the coreutils version by default. It can be used on any systems that don't provide a POSIX compliant external kill program. * build-aux/gen-lists-of-programs.sh: Move to the list of programs not built by default. * init.cfg: Add 2 new functions to verify the default kill available from the shell or the system is sufficient for use in various tests. * tests/du/move-dir-while-traversing.sh: Ensure trap supports signal names. * tests/misc/stty-invalid.sh: Likewise. * tests/misc/stty-pairs.sh: Likewise. * tests/misc/stty-row-col.sh: Likewise. * tests/misc/stty.sh: Likewise. * tests/misc/sort-compress.sh: Likewise. Also simplify trap call. * tests/install/trap.sh: Likewise. * tests/misc/timeout.sh: Likewise. * tests/dd/stats.sh: Likewise. Also use default kill command. * tests/misc/timeout-group.sh: Likewise. --- build-aux/gen-lists-of-programs.sh | 2 +- init.cfg | 14 ++++++++++++++ tests/dd/stats.sh | 3 ++- tests/du/move-dir-while-traversing.sh | 1 + tests/install/trap.sh | 4 ++-- tests/misc/sort-compress.sh | 4 ++-- tests/misc/stty-invalid.sh | 2 ++ tests/misc/stty-pairs.sh | 2 ++ tests/misc/stty-row-col.sh | 2 ++ tests/misc/stty.sh | 2 ++ tests/misc/timeout-group.sh | 4 +++- tests/misc/timeout.sh | 4 ++-- 12 files changed, 35 insertions(+), 9 deletions(-) diff --git a/build-aux/gen-lists-of-programs.sh b/build-aux/gen-lists-of-programs.sh index 40c3a32..cd1a2fa 100755 --- a/build-aux/gen-lists-of-programs.sh +++ b/build-aux/gen-lists-of-programs.sh @@ -19,6 +19,7 @@ disabled_by_default_progs=' arch coreutils hostname + kill ' # Programs that can be built only when certain requisite system @@ -73,7 +74,6 @@ normal_progs=' head id join - kill link ln logname diff --git a/init.cfg b/init.cfg index ef450d7..aaf2717 100644 --- a/init.cfg +++ b/init.cfg @@ -470,6 +470,20 @@ require_proc_pid_status_() kill $pid } +# Does trap support signal names? +# Old versions of ash did not. +require_trap_signame_() +{ + (trap '' CHLD) || skip_ 'requires trap with signal name support' +} + +# Does kill support sending signal to whole group? +# dash does not. +require_kill_group_() +{ + kill -0 -- -1 || skip_ 'requires kill with group signalling support' +} + # Return nonzero if the specified path is on a file system for # which FIEMAP support exists. Note some file systems (like ext3 and btrfs) # only support FIEMAP for files, not directories. diff --git a/tests/dd/stats.sh b/tests/dd/stats.sh index a82c66d..da2c2d2 100755 --- a/tests/dd/stats.sh +++ b/tests/dd/stats.sh @@ -18,8 +18,9 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ dd +require_trap_signame_ -env kill -l | grep '^INFO$' && SIGINFO='INFO' || SIGINFO='USR1' +kill -l | grep 'INFO' && SIGINFO='INFO' || SIGINFO='USR1' # This to avoid races in the USR1 case # as the dd process will terminate by default until diff --git a/tests/du/move-dir-while-traversing.sh b/tests/du/move-dir-while-traversing.sh index 67bb345..a90f1c4 100755 --- a/tests/du/move-dir-while-traversing.sh +++ b/tests/du/move-dir-while-traversing.sh @@ -18,6 +18,7 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ du +require_trap_signame_ # We use a python-inotify script, so... python -m pyinotify -h > /dev/null \ diff --git a/tests/install/trap.sh b/tests/install/trap.sh index 0851ba6..157d1bc 100755 --- a/tests/install/trap.sh +++ b/tests/install/trap.sh @@ -19,12 +19,12 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ ginstall +require_trap_signame_ # Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh. ( - # ash doesn't support "trap '' CHLD"; it knows only signal numbers. - sig=$(env kill -l CHLD 2>/dev/null) && trap '' $sig + trap '' CHLD # Before 2004-04-21, install would infloop, in the 'while (wait...' loop: exec ginstall -s "$abs_top_builddir/src/ginstall$EXEEXT" . diff --git a/tests/misc/sort-compress.sh b/tests/misc/sort-compress.sh index 584110e..7cb5df8 100755 --- a/tests/misc/sort-compress.sh +++ b/tests/misc/sort-compress.sh @@ -18,6 +18,7 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ sort +require_trap_signame_ seq -w 2000 > exp || framework_failure_ tac exp > in || framework_failure_ @@ -38,8 +39,7 @@ chmod +x gzip # Ensure 'sort' is immune to parent's SIGCHLD handler # Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh. ( - # ash doesn't support "trap '' CHLD"; it knows only signal numbers. - sig=$(env kill -l CHLD 2>/dev/null) && trap '' $sig + trap '' CHLD # This should force the use of child processes for "compression" PATH=.:$PATH exec sort -S 1k --compress-program=gzip in > /dev/null diff --git a/tests/misc/stty-invalid.sh b/tests/misc/stty-invalid.sh index 881146f..49c2086 100755 --- a/tests/misc/stty-invalid.sh +++ b/tests/misc/stty-invalid.sh @@ -19,6 +19,8 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ stty require_controlling_input_terminal_ +require_trap_signame_ + trap '' TTOU # Ignore SIGTTOU diff --git a/tests/misc/stty-pairs.sh b/tests/misc/stty-pairs.sh index 129c22f..0494343 100755 --- a/tests/misc/stty-pairs.sh +++ b/tests/misc/stty-pairs.sh @@ -23,6 +23,8 @@ expensive_ # Make sure there's a tty on stdin. require_controlling_input_terminal_ +require_trap_signame_ + trap '' TTOU # Ignore SIGTTOU # Get the reversible settings from stty.c. diff --git a/tests/misc/stty-row-col.sh b/tests/misc/stty-row-col.sh index 0616812..8c18df6 100755 --- a/tests/misc/stty-row-col.sh +++ b/tests/misc/stty-row-col.sh @@ -32,6 +32,8 @@ export LC_ALL print_ver_ stty require_controlling_input_terminal_ +require_trap_signame_ + trap '' TTOU # Ignore SIGTTOU # Versions of GNU stty from shellutils-1.9.2c and earlier failed diff --git a/tests/misc/stty.sh b/tests/misc/stty.sh index 5e39b72e..217891a 100755 --- a/tests/misc/stty.sh +++ b/tests/misc/stty.sh @@ -21,6 +21,8 @@ print_ver_ stty require_controlling_input_terminal_ +require_trap_signame_ + trap '' TTOU # Ignore SIGTTOU # Get the reversible settings from stty.c. diff --git a/tests/misc/timeout-group.sh b/tests/misc/timeout-group.sh index d47f0dc..faca2e7 100755 --- a/tests/misc/timeout-group.sh +++ b/tests/misc/timeout-group.sh @@ -18,6 +18,8 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ timeout +require_trap_signame_ +require_kill_group_ # construct a program group hierarchy as follows: # timeout-group - foreground group @@ -67,7 +69,7 @@ setsid ./group.sh & pid=$! retry_delay_ check_timeout_cmd_running .1 6 || fail=1 # Simulate a Ctrl-C to the group to test timely exit # Note dash doesn't support signalling groups (a leading -) -env kill -INT -- -$pid +kill -INT -- -$pid wait test -e int.received || fail=1 diff --git a/tests/misc/timeout.sh b/tests/misc/timeout.sh index 3cebd33..ec77d61 100755 --- a/tests/misc/timeout.sh +++ b/tests/misc/timeout.sh @@ -18,6 +18,7 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ timeout +require_trap_signame_ # no timeout timeout 10 true || fail=1 @@ -50,8 +51,7 @@ test $? = 124 && fail=1 # Ensure 'timeout' is immune to parent's SIGCHLD handler # Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh. ( - # ash doesn't support "trap '' CHLD"; it knows only signal numbers. - sig=$(env kill -l CHLD 2>/dev/null) && trap '' $sig + trap '' CHLD exec timeout 10 true ) || fail=1 -- 2.5.0
