How can I setup a keybinding to send a SIGKILL to the current foreground job? I already know that Ctrl-C is SIGINT and Ctrl-\ is SIGQUIT. I would like a more severe option.
Is there anything seriously unadvisable about this?
|
How can I setup a keybinding to send a SIGKILL to the current foreground job? I already know that Ctrl-C is SIGINT and Ctrl-\ is SIGQUIT. I would like a more severe option. Is there anything seriously unadvisable about this? |
|||
|
Unadvisable or not, it is actually impossible: The Control+[?] keybindings are actually handled by the tty driver and not by the shell, because as long as there is a process running in the foreground, input and output of your terminal will be forwarded directly to the process. The shell would never be able to act upon (or even see) your keypresses. You can get a list of the currently assigned Ctrl+[?] key combinations from Unfortunately, there is no way to send one of the two signals that can't be disabled by a process (SIGKILL and SIGSTOP), so if all of the three mentioned signals have no effect, you'll have to use some other way (e.g. another shell) to kill the foreground process. (Actually, in addition to catching all of the three signals, the foreground process can even disable the special key combinations in the first place by setting the tty to "raw" mode. SSH does this, for example – this is how it can relay a locally pressed Ctrl+C to the remote host.) |
||||
|
|
|
Yes, there's something inadvisable. You're leaping directly from the On that note, no-one else seems to have yet noticed that you are asking about shell line editor keybindings, not the terminal. To answer the first part of your question, then: You set up a shell function to send the signal to the "current" job.
Then you construct a ZLE user-defined widget that invokes this shell function.
Then, finally, you bind that widget to a key of your choice.
|
|||
|
zsh, and the fact that the question talks about keybindings. This is a question about configuringzsh's line editor, not about setting up one's terminal. – JdeBP May 26 '11 at 9:31