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 control characters?

up vote 4 down vote accepted

It's the difference between the "stop" and "suspend" actions to the terminal.

Stopping the output with Ctrl-S doesn't stop the process from running; rather it just stops output to the terminal (resume with Ctrl-Q / "start").

Suspending a process with Ctrl-Z actually stops it running, and puts the process into a different state visible from ps (state "T"). Resume with "fg" or "bg" to resume the process in the foreground or background, respectively.

CTRL-Z sends the SIGSTOP signal, which forces the program to stop.

With

fg

or

bg

you can send SIGCONT and start it in the front- or background.

CTRL-S just stops outputting stuff to the terminal. (XOFF) You can turn it back on with CTRL-Q.(XON)

  • A small correction: Control-Z sends SIGTSTP, not SIGSTOP. An important difference between them is that programs can catch or ignore SIGTSTP, but not SIGSTOP. Programs may catch TSTP and perform cleanup operations before suspending execution, but STOP causes the process to stop without any notice. – Chris Page Sep 19 '11 at 12:14

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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