Friday, May 3, 2024
30
rated 0 times [  30] [ 0]  / answers: 1 / hits: 9072  / 2 Years ago, mon, january 10, 2022, 11:27:30

So, I was playing some Zork 1 and I went to copy some text to show a friend of mine, but I accidentally forgot to hold the shift key when pressing CTRL+C. This stopped the command and I lost my Zork data...



Is there some sort of "helpful" tip out their that I can use to prevent stopping the command when press the keys CTRL+C?



Note that Zork is run inside of the terminal. It's a terminal-based game in which you give commands to perform different actions.


More From » command-line

 Answers
6

The key combination Ctrl+C sends the character ^C (byte value 3). This causes the terminal to send the SIGINT signal to the program running in the foreground¹. The conventional action for this signal is to interrupt the current command: programs designed to process successive commands go back to their toplevel prompt, while programs designed as a single batch command or a continuous interaction exit. Evidently the program you're using was designed according to the second model.



This signal-sending key is a feature of the general terminal interface in the kernel, shared by all terminal emulators and real physical terminals. You can configure which key sends this signal, as well as other keys (most notably CtrlZ sending SIGSTOP to suspend the foreground program) with the stty command. To switch the key for SIGINT to Ctrl+_ (in the current terminal):



stty intr '^_'


To disable it altogether:



stty intr ''


To reset all settings to the default:



stty sane


The key cannot be an arbitrary key combination, it has to be a single byte value. The stty setting can be overridden by programs — some programs (especially full-screen text mode programs) do their own keyboard shortcut processing.



¹ More precisely, to all the processes in the foreground process group for which the terminal is the controlling terminal.


[#24778] Wednesday, January 12, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tonhorn

Total Points: 196
Total Questions: 118
Total Answers: 95

Location: Vanuatu
Member since Fri, May 13, 2022
2 Years ago
;