^Z
Printable ASCII characters | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | _ | + | space | |||||||||||||||||||||
` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | { | } | | | |||||||||||||||||||
Ww | Ee | Rr | Tt | Yy | Uu | Ii | Oo | Pp | : | " | [ | ] | \ | |||||||||||||||||||||
Aa | Ss | Dd | Ff | Gg | Hh | Jj | Kk | Ll | ? | ; | ' | Ctrl | ||||||||||||||||||||||
Zz | Xx | Cc | Vv | Bb | Nn | Mm | , | . | / | < | > | Alt |
A user has suggested improving this page or section as follows:
"merge with Shell escape?"
The ^Z (ctrl + z) command suspends NetHack in environments that support this. ^Z is the usual *NIX shell keybind which suspends the foremost process, but NetHack is suspended using ^Z no matter what the current setting is. Windows' cmd.exe does not allow ^Z, but many *NIX shells will. When NetHack is suspended, the shell it was run from is brought into focus. NetHack is still alive, but it is frozen. Running the fg shell builtin will awaken NetHack.
NetHack sets the terminal to "raw mode", in which all incoming keystrokes go directly to the running program without any attempt by the device driver to interpret them. A terminal which displays a shell prompt is usually in "cooked mode", in which such nice features as backspace, or Ctrl-C to stop a program, or Ctrl-Z for job control, are handled by the driver. That's fine for a shell, which takes all input in complete lines terminated by the press of an ENTER or RETURN key; but it will not do for NetHack, which needs each key as it is, when it is pressed. Thus NetHack has to provide its own support for such things as backspace when it is appropriate, and for Ctrl-Z.
When you press Ctrl-Z, the function dosuspend
[1] is called; at this level Ctrl-Z works like any other command. dosuspend
sets the terminal back to "cooked mode" and then sends the signal SIGTSTP to NetHack itself, emulating the normal behavior of the terminal in "cooked mode".
If the signal SIGTSTP does not exist, then the job control is not supported, and Ctrl-Z does not work. Most modern Unix-like systems support job control, including all versions of Linux and BSD.
References
- ↑ ioctl.c in NetHack 1.3d, line 35: the corresponding code in NetHack 3.4.3 is in
sys/share/ioctl.c
, which has not been uploaded to NetHackWiki