2,032pages on
this wiki
Add New Page
Add New Page Talk0

The ^Z (Ctrl+z) command suspends NetHack in environments that support this. ^Z is the usual *NIX[1] 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[2] 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.


  2. NetHack 1.3d/ioctl.c, line 35; the corresponding code in NetHack 3.4.3 is in sys/share/ioctl.c, which has not been uploaded to Wikihack.

Also on Fandom

Random Wiki