Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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