Score:0

How to map special key combination to SIGINT with stty

ad flag

I understand that stty intr ^C (which is also the default) sets CTRL+C to send an interrupt to a process.

I would like to understand how to send other combinations that are not only CTRL plus a key (e.g. ALT+C).

In particular, I have a Mac keyboard and I used GNOME Tweaks to `Swap Left Win with Left Ctrl', and I'd like to map my physical key 'control' (which should now be remapped to 'command') and C to send an interrupt.

I repeat in case it's confusing. I'd like to press 'control' and C on my keyboard to send an interrupt while the two keys are swapped (as I want them). I simply want to follow the Mac standard to keep switching in my mind.

If I use showkey I get the following:

> showkey 
kb mode was ?UNKNOWN?
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]

press any key (program terminates 10s after last keypress)...
keycode  28 release
ckeycode  46 press (here I've pressed the key 'C')
keycode  46 release
keycode 125 press (here I've pressed the key 'command', remapped to 'control' with GNOME Tweaks)
keycode 125 release
keycode  29 press (here I've pressed the key 'control', remapped to 'command' with GNOME Tweaks)
keycode  29 release

I'd like to press keycode 29 and keycode 46 to send SIGINT.

Thank you.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.