brush version
master
bash version (for comparison)
No response
Platform / OS
Linux
Steps to reproduce
Run the following:
brush -c 'while :; do printf X; sleep 1; done'
and try to abort it using ctrl-C.
Similar scenario with the same symptoms: run an interactive brush shell, and then at the prompt run this line:
while :; do printf X; sleep 1; done
Actual behavior (brush)
It's effectively impossible to abort it (both test cases), despite many attempts with ctrl-C.
Expected behavior
With brush -c ...: brush always exits on first ctrl-C press.
With interactive brush shell: brush aborts the loop, prints the prompt, and is ready for new user input.
Additional context
First, this issue happens in both linux (musl) brush, and windows-brush. I did not test other binaries.
Here's an example terminal printout with quite a few ^C presses, sometimes several-per-second, and after giving up, killing it from another terminal (pkill brush - that was the only brush process running):
$ ./brush -c 'while :; do printf X; sleep 1; done'
XXXXXXX^CX^CXX^CX^CX^CX^CX^CX^CX^CX^CX^CX^CX^CXXX^CX^CX^CX^CX^CXXXTerminated
As evident from the output, and even more so when watching it unfold at the terminal, every ctrl-C press is immediately followed by a printout of X. This is even more evident if using e.g. sleep 10 instead of sleep 1.
So the ^C does interrupt the currently-running command (99.99999% of the attempts would be at the sleep 1 command), and then brush continues with the loop as if nothing happened, and the process just happened to exit.
However, testing this exact line with any other shell (tested dash, bash, zsh, busybox-ash), and the first ^C always exits that loop and the shell.
So when an interrupt happens while an external utility was running, brush should instead also apply it to whatever (shell) code which invoked that utility. Typically this means calling the trap code, if exists, and if not then exit that code/loop/shell/etc.
Care should be taken to not exit the shell itself if it's interactive.
brush version
master
bash version (for comparison)
No response
Platform / OS
Linux
Steps to reproduce
Run the following:
brush -c 'while :; do printf X; sleep 1; done'and try to abort it using ctrl-C.
Similar scenario with the same symptoms: run an interactive brush shell, and then at the prompt run this line:
Actual behavior (brush)
It's effectively impossible to abort it (both test cases), despite many attempts with ctrl-C.
Expected behavior
With
brush -c ...: brush always exits on first ctrl-C press.With interactive brush shell: brush aborts the loop, prints the prompt, and is ready for new user input.
Additional context
First, this issue happens in both linux (musl) brush, and windows-brush. I did not test other binaries.
Here's an example terminal printout with quite a few ^C presses, sometimes several-per-second, and after giving up, killing it from another terminal (
pkill brush- that was the only brush process running):As evident from the output, and even more so when watching it unfold at the terminal, every ctrl-C press is immediately followed by a printout of
X. This is even more evident if using e.g.sleep 10instead ofsleep 1.So the ^C does interrupt the currently-running command (99.99999% of the attempts would be at the
sleep 1command), and then brush continues with the loop as if nothing happened, and the process just happened to exit.However, testing this exact line with any other shell (tested dash, bash, zsh, busybox-ash), and the first ^C always exits that loop and the shell.
So when an interrupt happens while an external utility was running, brush should instead also apply it to whatever (shell) code which invoked that utility. Typically this means calling the
trapcode, if exists, and if not then exit that code/loop/shell/etc.Care should be taken to not exit the shell itself if it's interactive.