From 830648aa639e697f417b7ac47c4da5cfdf1fcdb8 Mon Sep 17 00:00:00 2001 From: Andy C Date: Fri, 4 Feb 2022 00:10:52 -0500 Subject: [PATCH] [interactive] Set signal state for SIGTTIN, SIGTTOU, etc. Apparently job control shells need this. Still needs more testing. Also test signal state against bin/osh. --- core/pyos.py | 18 +++++++++++++++--- devtools/sigparse.sh | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/core/pyos.py b/core/pyos.py index b44ca89a30..0f3c9b7eac 100644 --- a/core/pyos.py +++ b/core/pyos.py @@ -271,18 +271,24 @@ def __call__(self, sig_num, unused_frame): def SignalState_AfterForkingChild(): # type: () -> None """Not a member of SignalState since we didn't do dependency injection.""" - # Respond to Ctrl-\ (core dump) - signal.signal(signal.SIGQUIT, signal.SIG_DFL) - # Python sets SIGPIPE handler to SIG_IGN by default. Child processes # shouldn't have this. # https://docs.python.org/2/library/signal.html # See Python/pythonrun.c. signal.signal(signal.SIGPIPE, signal.SIG_DFL) + # Respond to Ctrl-\ (core dump) + signal.signal(signal.SIGQUIT, signal.SIG_DFL) + # Child processes should get Ctrl-Z. signal.signal(signal.SIGTSTP, signal.SIG_DFL) + # More signals from + # https://www.gnu.org/software/libc/manual/html_node/Launching-Jobs.html + signal.signal(signal.SIGTTOU, signal.SIG_DFL) + signal.signal(signal.SIGTTIN, signal.SIG_DFL) + signal.signal(signal.SIGCHLD, signal.SIG_DFL) + class SignalState(object): """All changes to global signal state go through this object.""" @@ -306,6 +312,12 @@ def InitInteractiveShell(self, display): # This prevents Ctrl-Z from suspending OSH in interactive mode. signal.signal(signal.SIGTSTP, signal.SIG_IGN) + # More signals from + # https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html + signal.signal(signal.SIGTTOU, signal.SIG_IGN) + signal.signal(signal.SIGTTIN, signal.SIG_IGN) + signal.signal(signal.SIGCHLD, signal.SIG_IGN) + # Register a callback to receive terminal width changes. # NOTE: In line_input.c, we turned off rl_catch_sigwinch. diff --git a/devtools/sigparse.sh b/devtools/sigparse.sh index b401e2a5b9..1c553f9e65 100755 --- a/devtools/sigparse.sh +++ b/devtools/sigparse.sh @@ -34,7 +34,7 @@ report() { } compare-shells() { - local -a shells=(bash dash mksh zsh osh) + local -a shells=(bash dash mksh zsh bin/osh) # Hm non-interactive shells have consistency. # SIGCHLD and SIGINT are caught in bash, dash, zsh, mksh. mksh catches @@ -62,7 +62,7 @@ compare-shells() { local more_flags='' case $sh in - (bash|osh) + (bash|bin/osh) more_flags='--rcfile /dev/null' ;; esac