Skip to content

Commit d131655

Browse files
committed
Support SIGQUIT (quit) signal for +stop-signal
1 parent ec6a3c8 commit d131655

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

byexample/modules/shell.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def extend_option_parser(self, parser):
103103
)
104104
parser.add_argument(
105105
"+stop-signal",
106-
choices=['suspend', 'eof', 'interrupt'],
106+
choices=['suspend', 'eof', 'interrupt', 'quit'],
107107
default='suspend',
108108
help=
109109
"signal to send when stop-on-timeout/stop-on-silence is used (suspend ^Z by default)."
@@ -201,7 +201,19 @@ def _run_impl(self, example, options):
201201
self._sendcontrol('d')
202202
elif stop_signal == "interrupt":
203203
self._sendcontrol('c')
204+
elif stop_signal == "quit":
205+
self._sendcontrol('\\')
204206
else:
207+
# Note: we could send any signal but experiment shows that
208+
# some of the signals are catched by the shell. SIGKILL for
209+
# example kills the interpreter.
210+
# Other control sequences can break the flow of the terminal
211+
# like ^Q and ^S which start and stop the flow. These are
212+
# too risky to use.
213+
# For these reasons we don't support arbitrary signals
214+
# If the user want to send an arbitrary signal, it should
215+
# use ^Z (suspend) and then run
216+
# kill -NN and send the signal that the user wants.
205217
raise ValueError(
206218
"Unexpected stop-signal '%s'" % stop_signal
207219
)

0 commit comments

Comments
 (0)