• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision4114 (tree)
Time2020-10-11 23:01:13
Authormagicant

Log Message

Allow trapping SIGINT/SIGQUIT in asynchronous list (#40767)

Change Summary

Incremental Difference

--- yash/trunk/NEWS (revision 4113)
+++ yash/trunk/NEWS (revision 4114)
@@ -26,7 +26,9 @@
2626 the pathnames of external commands with a redundant leading slash
2727 when the current working directory is "/" or "//".
2828 * When an EXIT trap is executed in a subshell with a redirection,
29- the redirection was incorrectly not begin applied to the trap.
29+ the redirection was incorrectly not being applied to the trap.
30+ * When job control is off, the "trap" built-in was failing to set
31+ a new trap for SIGINT and SIGQUIT in an asynchronous list.
3032 * In pattern matching, when an unescaped backslash results from an
3133 expansion in the pattern, it is now treated as an escape
3234 character.
--- yash/trunk/sig.c (revision 4113)
+++ yash/trunk/sig.c (revision 4114)
@@ -90,7 +90,7 @@
9090 static void sig_handler(int signum);
9191 static void handle_sigchld(void);
9292 static void set_trap(int signum, const wchar_t *command);
93-static bool is_ignored(int signum);
93+static bool is_originally_ignored(int signum);
9494 static void banish_phantoms(void);
9595 #if YASH_ENABLE_LINEEDIT
9696 # ifdef SIGWINCH
@@ -867,7 +867,7 @@
867867 receivedp = &signal_received[index];
868868 }
869869
870- if (!is_interactive && *commandp == NULL && is_ignored(signum)) {
870+ if (!is_interactive && *commandp == NULL && is_originally_ignored(signum)) {
871871 /* Signals that were ignored on entry to a non-interactive shell cannot
872872 * be trapped or reset. (POSIX) */
873873 #if FIXED_SIGNAL_AS_ERROR
@@ -952,9 +952,9 @@
952952 }
953953 }
954954
955-/* Checks if the specified signal is ignored.
956- * Asserts the shell is not interactive. */
957-bool is_ignored(int signum)
955+/* Checks if the specified signal was originally ignored when the shell was
956+ * invoked. Asserts the shell is not interactive. */
957+bool is_originally_ignored(int signum)
958958 {
959959 assert(!is_interactive_now);
960960
@@ -961,14 +961,13 @@
961961 if (signum == 0)
962962 return false;
963963
964- if (doing_job_control_now &&
965- (signum == SIGTTIN || signum == SIGTTOU || signum == SIGTSTP))
966- return sigismember(&officially_ignored_signals, signum);
964+ if (sigismember(&originally_ignored_signals, signum))
965+ return true;
966+ if (sigismember(&originally_defaulted_signals, signum))
967+ return false;
967968
968- struct sigaction action;
969- sigemptyset(&action.sa_mask);
970- return sigaction(signum, NULL, &action) >= 0
971- && action.sa_handler == SIG_IGN;
969+ xsigaction(signum, NULL, NULL);
970+ return sigismember(&originally_ignored_signals, signum);
972971 }
973972
974973 /* Clears the EXIT trap. */
Show on old repository browser