3

When using a terminal emulator, one can stop the currently running program with either CTRL-Z or CTRL-S. What's the difference between these signals?

10

Ctrl-Z does in fact stop the current foreground program, but it has nothing to do with the terminal emulator. It is handled by the shell you are currently running. The original shells for Unix didn't have this feature, so you might find that you are missing it on some systems, say a minimal embedded version of Linux booted into single user mode.

Ctrl-S doesn't necessarily stop the current foreground program at all. All it does is request that the OS's terminal code temporarily stop sending data to your terminal. The program is actually still running, and in fact as long as it doesn't fill any output buffers, it won't even get blocked on a system call. The Ctrl-S terminal output pause feature is an ancient de facto standard dating back to the days of teletypes, and is supported in all Unixy operating systems by convention, but it it can be disabled (stty -ixon) or rebound to something else. Text editors and other interactive programs often rebind Ctrl-S, for example.

You can see further differences in how you restart things after stopping. Ctrl-Q restarts terminal output after a Ctrl-S, while restarting a process stopped with Ctrl-Z requires a fg command to the controlling shell.

3

One pauses and backgrounds a job, one freezes it in place. With Z, you are returned to a terminal and can run commands like bg to continue the job in the background or fg to continue in the foreground. With S you are just left with a frozen program staring you in the face.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.