File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,11 @@ def _start_bash(self):
109109 # reset it from the subprocess. Since kernelapp ignores SIGINT except in
110110 # message handlers, we need to temporarily reset the SIGINT handler here
111111 # so that bash and its children are interruptible.
112- sig = signal .signal (signal .SIGINT , signal .SIG_DFL )
112+ old_sigint_handler = signal .signal (signal .SIGINT , signal .SIG_DFL )
113+ # We need to temporarily reset the default signal handler for SIGPIPE so
114+ # that commands like `head` used in a pipe chain can signal to the data
115+ # producers.
116+ old_sigpipe_handler = signal .signal (signal .SIGPIPE , signal .SIG_DFL )
113117 try :
114118 # Note: the next few lines mirror functionality in the
115119 # bash() function of pexpect/replwrap.py. Look at the
@@ -131,7 +135,8 @@ def _start_bash(self):
131135 extra_init_cmd = "export PAGER=cat" ,
132136 line_output_callback = self .process_output )
133137 finally :
134- signal .signal (signal .SIGINT , sig )
138+ signal .signal (signal .SIGINT , old_sigint_handler )
139+ signal .signal (signal .SIGPIPE , old_sigpipe_handler )
135140
136141 # Disable bracketed paste (see <https://github.com/takluyver/bash_kernel/issues/117>)
137142 self .bashwrapper .run_command ("bind 'set enable-bracketed-paste off' >/dev/null 2>&1 || true" )
You can’t perform that action at this time.
0 commit comments