Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages

From: Pádraig Brady <[email-masked]>
Date: Sun, 3 Mar 2019 16:07:39 -0800

On 03/03/19 15:36, Pádraig Brady wrote:
> On 25/02/19 22:35, Pádraig Brady wrote:
>> Thanks for doing all that.
>> I've attached a few changes:
>>
>> - spelling fixes
>> - usage() clarified/reordered
>> - ensure sigset_t are initialized
>> - Don't setprocmask() unless specified
>> - Simplified SETMASK_SIGNAL_OPTION handling
>> - The test missed `env` as a prerequisite
>> - The test was slow/spun cpu, so used sleep instead of seq
>> - Used $SHELL in case sh didn't support trap
>>
>> I see that the last signal that `kill -l` lists is not included.
>> I think we should be processing SIGNUM_BOUND also?
> 
> An additional patch attached to replace --list-signal-actions
> with --list-ignored-signals.  This is simpler, and more symmetric
> with the other options. Also the extra output was moot I think
> since handlers are reset upon exec

I've locally adjusted the NEWS/texi for that patch also.
I've a local patch to include SIGNUM_BOUND which I won't spam the list with.

Attached is a patch to remove the -p and --set-mask options,
which I've a light preference for.
I'll think some more about it.

cheers,
Pádraig

>From ae8d2ab5d9a380051a1ae1d315832e98f40ff456 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email-masked]>
Date: Sun, 3 Mar 2019 16:02:55 -0800
Subject: [PATCH] env: remove shortcut signal handling options

* src/env.c: Remove -p and --setmask-signal
---
 doc/coreutils.texi               |  9 ---------
 src/env.c                        | 16 ----------------
 tests/misc/env-signal-handler.sh | 10 ----------
 3 files changed, 35 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 4dea101..3c220ea 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -17305,10 +17305,6 @@ Block signal(s) @var{sig} from being delivered.
 @item --unblock-signal[=@var{sig}]
 Unblock signal(s) @var{sig}.
 
-@item --setmask-signal[=@var{sig}]
-Set list of blocked signals to @var{sig}. All other signals will be unblocked.
-
-
 @item --list-blocked-signals
 List blocked (masked) signals and exit.
 If no signals are blocked, nothing is printed.
@@ -17317,11 +17313,6 @@ If no signals are blocked, nothing is printed.
 List ignored signals and exit.
 If no signals are ignored, nothing is printed.
 
-
-@item -p
-Equivalent to @option{--default-signal=PIPE} - sets SIGPIPE to its default
-behavior (terminate a program upon @samp{SIGPIPE}).
-
 @item -v
 @itemx --debug
 @opindex -v
diff --git a/src/env.c b/src/env.c
index 90821c3..7bc3c7b 100644
--- a/src/env.c
+++ b/src/env.c
@@ -80,7 +80,6 @@ enum
   IGNORE_SIGNAL_OPTION,
   BLOCK_SIGNAL_OPTION,
   UNBLOCK_SIGNAL_OPTION,
-  SETMASK_SIGNAL_OPTION,
   LIST_BLOCKED_SIGNALS_OPTION,
   LIST_IGNORED_SIGNALS_OPTION,
 };
@@ -95,7 +94,6 @@ static struct option const longopts[] =
   {"ignore-signal",  optional_argument, NULL, IGNORE_SIGNAL_OPTION},
   {"block-signal",   optional_argument, NULL, BLOCK_SIGNAL_OPTION},
   {"unblock-signal", optional_argument, NULL, UNBLOCK_SIGNAL_OPTION},
-  {"setmask-signal", optional_argument, NULL, SETMASK_SIGNAL_OPTION},
   {"list-blocked-signals", no_argument, NULL, LIST_BLOCKED_SIGNALS_OPTION},
   {"list-ignored-signals", no_argument, NULL,  LIST_IGNORED_SIGNALS_OPTION},
   {"debug", no_argument, NULL, 'v'},
@@ -140,9 +138,6 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\
       --unblock-signal[=SIG]  unblock delivery of SIG signal(s) to COMMAND\n\
 "), stdout);
       fputs (_("\
-      --setmask-signal[=SIG]  set full mask with SIG signal(s) blocked\n\
-"), stdout);
-      fputs (_("\
       --default-signal[=SIG]  reset handling of SIG signal(s) to the default\n\
 "), stdout);
       fputs (_("\
@@ -155,9 +150,6 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\
       --list-blocked-signals  list blocked (masked) signals and exit\n\
 "), stdout);
       fputs (_("\
-  -p                   same as --default-signal=PIPE\n\
-"), stdout);
-      fputs (_("\
   -v, --debug          print verbose information for each processing step\n\
 "), stdout);
       fputs (HELP_OPTION_DESCRIPTION, stdout);
@@ -845,10 +837,6 @@ main (int argc, char **argv)
         case '0':
           opt_nul_terminate_output = true;
           break;
-        case 'p':
-          /* alias to --default-signal=PIPE */
-          signals[SIGPIPE] = DEFAULT;
-          break;
         case DEFAULT_SIGNAL_OPTION:
           parse_signal_action_params (optarg, true);
           break;
@@ -861,10 +849,6 @@ main (int argc, char **argv)
         case UNBLOCK_SIGNAL_OPTION:
           parse_block_signal_params (optarg, false);
           break;
-        case SETMASK_SIGNAL_OPTION:
-          parse_block_signal_params (NULL, false);
-          parse_block_signal_params (optarg, true);
-          break;
         case LIST_BLOCKED_SIGNALS_OPTION:
           list_blocked_signals ();
           break;
diff --git a/tests/misc/env-signal-handler.sh b/tests/misc/env-signal-handler.sh
index 4dd90c2..5e6b57e 100755
--- a/tests/misc/env-signal-handler.sh
+++ b/tests/misc/env-signal-handler.sh
@@ -63,16 +63,6 @@ compare exp-err1 err1 || framework_failure_
 compare exp-out out2 || fail=1
 compare /dev/null err2 || fail=1
 
-# env test - default signal handler (2)
-# -------------------------------------
-# Repeat the previous test, using "-p" (shortcut for --default-signal=PIPE):
-(trap '' PIPE;
- env -p \
-    $SHELL -c 'trap - PIPE; seq 999999 2>err3 | head -n1 > out3')
-
-compare exp-out out3 || fail=1
-compare /dev/null err3 || fail=1
-
 # env test - default signal handler (3)
 # -------------------------------------
 # Repeat the previous test, using --default-signal with no signal names,
-- 
2.9.3