I want to launch a continuous running command with xterm or urxvt and after pressing Ctrl+C to exit the command I want to get a shell to enter further commands in the same window.
With non-continuous running commands I can do
urxvt -hold -e sh -c "echo foo; sh"
But with continuous running commands this does not work
urxvt -hold -e sh -c "tail -f /dev/null; sh"
After pressing Ctrl+C the command is killed but urxvt enters an unresponsive state and does not open a shell. Same thing happens with xterm.
Any solutions for this?
Ctrl+C generates a
SIGINT
signal,bash
stops the entire sequence by default. It actually lets the signal pass to the current command, and analyses the exit status of rhe command - if the command handled theSIGINT
,bash
continues the script, otherwise theSIGINT
shows up in the exit status andbash
terminates the command sequence.There's an explanation here: https://unix.stackexchange.com/questions/479023/why-does-this-script-keep-running-after-receiving-sigint
In that case, the questioner used
sudo
to wrap the command with a signal handler. You could also look at using a subshell with thetrap
command.(Asker reports that this works:
urxvt -e sh -c "trap sh SIGINT; tail -f /dev/null"
)