• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision4115 (tree)
Time2020-10-11 23:01:14
Authormagicant

Log Message

Ignore SIGINT/SIGQUIT/SIGTSTP after phantomizing traps

The phantomize_traps' function was overwriting the results of the
ignore_sigquit_and_sigint' and ignore_sigtstp' functions. This commit
reorders the function calls.

Change Summary

Incremental Difference

--- yash/trunk/NEWS (revision 4114)
+++ yash/trunk/NEWS (revision 4115)
@@ -29,6 +29,9 @@
2929 the redirection was incorrectly not being applied to the trap.
3030 * When job control is off, the "trap" built-in was failing to set
3131 a new trap for SIGINT and SIGQUIT in an asynchronous list.
32+ * When job control is off, SIGINT and SIGQUIT were not being
33+ ignored if a trap had been set for the signal the main shell
34+ process.
3235 * In pattern matching, when an unescaped backslash results from an
3336 expansion in the pattern, it is now treated as an escape
3437 character.
--- yash/trunk/exec.c (revision 4114)
+++ yash/trunk/exec.c (revision 4115)
@@ -159,7 +159,7 @@
159159 __attribute__((nonnull));
160160 static inline void connect_pipes(pipeinfo_T *pi)
161161 __attribute__((nonnull));
162-static void become_child(bool leave);
162+static void become_child(sigtype_T sigtype);
163163 static void search_command(
164164 const char *restrict name, const wchar_t *restrict wname,
165165 commandinfo_T *restrict ci, enum srchcmdtype_T type)
@@ -803,7 +803,7 @@
803803 if (c->c_type == CT_SUBSHELL)
804804 /* No command follows this subshell command, so we can execute the
805805 * subshell directly in this process. */
806- become_child(false);
806+ become_child(0);
807807 } else {
808808 /* fork first if `type' is E_ASYNC, the command type is subshell,
809809 * or there is a pipe. */
@@ -1022,8 +1022,7 @@
10221022 sigprocmask(SIG_SETMASK, &savemask, NULL);
10231023 } else {
10241024 /* child process */
1025- bool save_doing_job_control_now = doing_job_control_now;
1026- if (save_doing_job_control_now && pgid >= 0) {
1025+ if (doing_job_control_now && pgid >= 0) {
10271026 setpgid(0, pgid);
10281027 if (pgid == 0)
10291028 pgid = getpgrp();
@@ -1031,22 +1030,16 @@
10311030 if (fg)
10321031 put_foreground(pgid);
10331032 }
1034- if (sigtype & t_quitint)
1035- if (!save_doing_job_control_now)
1036- ignore_sigquit_and_sigint();
1037- if (sigtype & t_tstp)
1038- if (save_doing_job_control_now)
1039- ignore_sigtstp();
1040- become_child(sigtype & t_leave); /* signal mask is restored here */
1033+ become_child(sigtype); /* signal mask is restored here */
10411034 }
10421035 return cpid;
10431036 }
10441037
10451038 /* Resets traps, signal handlers, etc. for the current process to become a
1046- * subshell. See `fork_and_reset' for the meaning of the `leave' argument. */
1047-void become_child(bool leave)
1039+ * subshell. See `fork_and_reset' for the meaning of the `sigtype' parameter. */
1040+void become_child(sigtype_T sigtype)
10481041 {
1049- if (leave) {
1042+ if (sigtype & t_leave) {
10501043 clear_exit_trap();
10511044 } else {
10521045 phantomize_traps();
@@ -1056,8 +1049,16 @@
10561049 #endif
10571050 reset_execstate(true);
10581051 }
1059- restore_signals(leave); /* signal mask is restored here */
1060- clear_shellfds(leave);
1052+
1053+ if (sigtype & t_quitint)
1054+ if (!doing_job_control_now)
1055+ ignore_sigquit_and_sigint();
1056+ if (sigtype & t_tstp)
1057+ if (doing_job_control_now)
1058+ ignore_sigtstp();
1059+
1060+ restore_signals(sigtype & t_leave); /* signal mask is restored here */
1061+ clear_shellfds(sigtype & t_leave);
10611062 is_interactive_now = false;
10621063 suppresserrreturn = false;
10631064 exitstatus = -1;
Show on old repository browser