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?
Asked
Active
Viewed 3,477 times
6
-
http://superuser.com/questions/243460/what-to-do-when-ctrl-c-cant-kill-a-process/243472#243472 – akira May 23 '11 at 13:19
2 Answers
4
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.
PhilR
- 534
- 2
- 8
-
`rather it just stops output to the terminal` -- it generally pauses the application as a side effect – Eugene Yarmash May 23 '11 at 14:17
-
If the app tries to read from/write to the terminal, it will pause, yes. If not, the app keeps running. This is one of the significant differences between the two methods. – PhilR May 23 '11 at 14:43
-
Sidenote: many shells support [Ctrl-Y to background a process, and only suspend on the first request for terminal input. This is known as _delayed suspend](http://www.gnu.org/software/bash/manual/bashref.html#Job-Control-Basics)_ – sehe May 23 '11 at 15:37
-
3
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)
cularis
- 1,239
- 8
- 10
-
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