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

From: Pádraig Brady <[email-masked]>
Date: Sun, 3 Mar 2019 17:47:24 -0800

On 03/03/19 16:59, Pádraig Brady wrote:
> A summary of the all signal options in my local set now is:
> 
>   --block-signal[=SIG]    block delivery of SIG signal(s) to COMMAND
>   --unblock-signal[=SIG]  unblock delivery of SIG signal(s) to COMMAND
>   --default-signal[=SIG]  reset handling of SIG signal(s) to the default
>   --ignore-signal[=SIG]   set handling of SIG signals(s) to do nothing
>   --list-signal-handling  list non default signal handling to stderr

I think we might be also able to remove --unblock-signal,
and just have --default-signal.

I.E. I don't think one would want to set default signal handling,
but leave a signal blocked?  Also I don't think one would
want to unblock a signal, but leave it ignored?
At least not and the level of env just exec()ing a program.
Anyway if those weird cases are needed, they can be achieved
by combining the options.

The attached does that, leaving us with:

--block-signal[=SIG]    block delivery of SIG signal(s) to COMMAND
--default-signal[=SIG]  reset handling of SIG signal(s) to the default
--ignore-signal[=SIG]   set handling of SIG signals(s) to do nothing
--list-signal-handling  list non default signal handling to stderr

cheers,
Pádraig.
From 7183477b7a5d9531a43b48beee8906ea7ae6fc06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email-masked]>
Date: Sun, 3 Mar 2019 17:40:34 -0800
Subject: [PATCH] env: have --default-signal imply --unblock-signal

Remove --unblock as i's not needed in isolation
---
 doc/coreutils.texi | 12 +++++-------
 src/env.c          |  9 +--------
 2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 0e4ed16..8112034 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -17247,10 +17247,11 @@ env --chdir=/build FOO=bar timeout 5 true
 @end example
 
 @item --default-signal[=@var{sig}]
-Reset signal @var{sig} to its default signal handler. Without @var{sig} all
-known signals are reset to their defaults. Multiple signals can be
-comma-separated. The following command runs @command{seq} with SIGINT and
-SIGPIPE set to their default (which is to terminate the program):
+Unblock and reset signal @var{sig} to its default signal handler.
+Without @var{sig} all known signals are reset to their defaults.
+Multiple signals can be comma-separated. The following command runs
+@command{seq} with SIGINT and SIGPIPE set to their default
+(which is to terminate the program):
 
 @example
 env --default-signal=PIPE,INT seq 1000 | head -n1
@@ -17302,9 +17303,6 @@ env --default-signal=INT,PIPE --ignore-signal=INT
 @item --block-signal[=@var{sig}]
 Block signal(s) @var{sig} from being delivered.
 
-@item --unblock-signal[=@var{sig}]
-Unblock signal(s) @var{sig}.
-
 @item --list-blocked-signals
 List blocked (masked) signals and exit.
 If no signals are blocked, nothing is printed.
diff --git a/src/env.c b/src/env.c
index 9a910da..aa0cfbc 100644
--- a/src/env.c
+++ b/src/env.c
@@ -82,7 +82,6 @@ enum
   DEFAULT_SIGNAL_OPTION = CHAR_MAX + 1,
   IGNORE_SIGNAL_OPTION,
   BLOCK_SIGNAL_OPTION,
-  UNBLOCK_SIGNAL_OPTION,
   LIST_SIGNAL_HANDLING_OPTION,
 };
 
@@ -95,7 +94,6 @@ static struct option const longopts[] =
   {"default-signal", optional_argument, NULL, DEFAULT_SIGNAL_OPTION},
   {"ignore-signal",  optional_argument, NULL, IGNORE_SIGNAL_OPTION},
   {"block-signal",   optional_argument, NULL, BLOCK_SIGNAL_OPTION},
-  {"unblock-signal", optional_argument, NULL, UNBLOCK_SIGNAL_OPTION},
   {"list-signal-handling", no_argument, NULL,  LIST_SIGNAL_HANDLING_OPTION},
   {"debug", no_argument, NULL, 'v'},
   {"split-string", required_argument, NULL, 'S'},
@@ -136,9 +134,6 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\
       --block-signal[=SIG]    block delivery of SIG signal(s) to COMMAND\n\
 "), stdout);
       fputs (_("\
-      --unblock-signal[=SIG]  unblock delivery of SIG signal(s) to COMMAND\n\
-"), stdout);
-      fputs (_("\
       --default-signal[=SIG]  reset handling of SIG signal(s) to the default\n\
 "), stdout);
       fputs (_("\
@@ -823,6 +818,7 @@ main (int argc, char **argv)
           break;
         case DEFAULT_SIGNAL_OPTION:
           parse_signal_action_params (optarg, true);
+          parse_block_signal_params (optarg, false);
           break;
         case IGNORE_SIGNAL_OPTION:
           parse_signal_action_params (optarg, false);
@@ -830,9 +826,6 @@ main (int argc, char **argv)
         case BLOCK_SIGNAL_OPTION:
           parse_block_signal_params (optarg, true);
           break;
-        case UNBLOCK_SIGNAL_OPTION:
-          parse_block_signal_params (optarg, false);
-          break;
         case LIST_SIGNAL_HANDLING_OPTION:
           report_signal_handling = true;
           break;
-- 
2.9.3