Default in most terminal you can press ctrl\ to send a SIGQUIT signal to the process.
However on my keyboard to type a backslash, you have to do it like this: altshift7
Doing ctrlaltshift7 doesn't work, so how should I do the keyboard shortcut?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityDefault in most terminal you can press ctrl\ to send a SIGQUIT signal to the process.
However on my keyboard to type a backslash, you have to do it like this: altshift7
Doing ctrlaltshift7 doesn't work, so how should I do the keyboard shortcut?
I had to figure out the exact same thing today, with a German keyboard and in Ubuntu. So I've come up with the script below. Finding the right key still needs trial and error, but it's pretty simple that way.
For the record, Ctrl-4 did the trick in my case.
#!/usr/bin/bash
# Shows character codes while typing. More to the point, it also captures signals.
# Trap function
sig() {
printf '\t\t\t%s\t(re-enabled now, works next time)\n' "$1"
# A trap disables itself after being called once.
trap - $1
}
# Setting traps for all signals
mapfile -t signals < <(trap -l | grep -Eo SIG[-+A-Z0-9]+)
for signal in "${signals[@]}"; do
trap "sig $signal" "$signal"
done
# Display characters
printf "Start typing to examine characters and signals. Exit with Ctrl-C (twice).\n\n"
printf "Char\tDec\t Hex\tSignal\n"
while IFS= read -rN 1 char; do
LC_CTYPE=C printf '\t%3d\t0x%02X\n' "'$char" "'$char"
done
I don’t know how you can type Ctrl+\, but I can give you an alternative way to generate SIGQUIT from the keyboard. Find a character that you can type as a simple key combination. This probably needs to map to a (single) ASCII character (i.e., a single byte); e.g., Ctrl+A. Then type
stty quit ^A
That can be either
stty
quit
Ctrl+A Enter
(if you get an error message, try typing Ctrl+V
before the Ctrl+A)
or literally
sttyquit
^A Enter
(if you get an error message, try putting the ^A in quotes).
Then type a command like
sleep 9
,
press your key combination (i.e., Ctrl+A),
and see whether the program quits
as you would expect for Ctrl+\.
If you find a combination that works, put it (the stty quit
command)
into your .login
, .profile
, .bashrc
,
or whatever initialization command file you use.
I had almost the same problem with a french "azerty" keyboard.
To get the backslash character \
, I have to press altshift/.
But pressing ctrlaltshift/ does not send any signal, it just inserts a dot .
in the Terminal.
I found that pressing ctrl` (the backtick or backquote key) does send the SIGQUIT
signal:
$ sleep 9
^\Quit: 3
Pressing ctrlshift` also works.
Note that, on a french keyboard, "shifting" the backtick character (i.e. pressing shift`) produces the Pound sign £.
You can get the list of all signals with the kill -l
command:
$ kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGABRT 7) SIGEMT 8) SIGFPE
9) SIGKILL 10) SIGBUS 11) SIGSEGV 12) SIGSYS
13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGURG
17) SIGSTOP 18) SIGTSTP 19) SIGCONT 20) SIGCHLD
21) SIGTTIN 22) SIGTTOU 23) SIGIO 24) SIGXCPU
25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH
29) SIGINFO 30) SIGUSR1 31) SIGUSR2
ctrl + `
is the only way to exit an Elixir shell with only one shortcut on a french MacOS keyboard.
Jun 6, 2020 at 22:24
Have you tried mapping a different key to ^\
?
For instance (in macOS terminal):
Go to “Terminal -> Preferences -> Settings -> Keyboard”, click the +
and map something like control+f4 to \034
.
Ctrl
+ 4
Ctrl-\ is likely to generate ASCII code 28. Try doing something else that sends ASCII code 28.
For instance, maybe try this: hold down Alt, and then pressing 2 on the numpad, and then 8 on the numpad, and then releasing the Alt key. (Granted, if you have troubles hitting backslash, maybe you have troubles using numpad keys.) I don't have a Mac by me, but that works on many Unix-ish systems (and DOS/Microsoft Windows), so may be worth giving a shot.
If you are interacting with a remote system, you could put the character in a file and then some terminal software would let you use an "ASCII upload" to send the keystroke.
Another possible resource: AppleScript: sending keys for OSX