2

If I want to have more than 2 key sequence for binding to the suspend signal, how would I do that? To clarify, Ctrlz is for suspending. But if I want Ctrlz and a k with the previous 2 keys depressed to perform the same function, how would I do that?

I have tried various combos w success. For eg:

stty susp \^ZV

I use a tty terminal so emulators like xterm will not help in my case.

0

1 Answer 1

2

stty susp tells the terminal driver what character (actually what byte), when received unescaped from the terminal (via the wire if a real terminal, or written to the master side of a pseudo-terminal in case of a terminal emulator or sshd...), when ISIG is on, causes a SIGTSTP to be sent to the foreground job.

There's no key or keyboard involved here. It's the ^Z character by default (0x1a). xterm and other terminal emulators generally send that character when you press Z while holding the Ctrl key.

If you want to make it harder to suspend a process, you could configure your terminal emulator so that it doesn't send ^Z upon Ctrl+Z, but upon some other key combination. With xterm:

xterm -xrm 'XTerm.VT100.translations: #override \
  Ctrl Shift <KeyPress> X: string(0x1a)\nCtrl <KeyPress> Z:'

Sends the ^Z character upon pressing Ctrl+Shift+X, not upon Ctrl-Z. With xterm, I don't think you can specify arbitrary key combinations, you can only use modifier keys like Ctrl or Shift.

Of course, you could also define a different byte for stty susp and have xterm send it on a different key combination.

Note that you probably don't want to make it a byte over 0x7f as those would appear in different UTF-8 characters.

5
  • If I do stty susp \^K , then I would have changed it to Ctrl K. Is there a wayI can do it using stty instead of xterm? Feb 5, 2014 at 19:52
  • @sunyata, I'm not sure I understand your question, if you do stty susp \^K, same as stty susp $'\xb', you're telling the terminal driver to suspend upon the 0xb character. That character is usually sent by xterm upon pressing Ctrl+K, but you can configure xterm to send it upon a different event. Feb 5, 2014 at 20:07
  • I use a tty so xterm will not help. Feb 28, 2014 at 1:25
  • @sunyata, what do you mean by tty? a Tele-typewriter? A Linux virtual console? In the latter case, the equivalent would be to modify the kernel key map (look at man 5 keymap). Jun 19, 2014 at 9:59
  • By tty, I refer to a linux local terminal. I have since moved project so I no longer have the same environment to try things out. Thanks for your response. Jun 20, 2014 at 14:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .