Results 1 to 5 of 5
I wanna ask something regarding Linux shortcut in terminal. If we press ctrl+c, the program will be killed right? I just wonder are we sending SIGTERM or SIGKILL to that ...
- 10-27-2008 #1
Ctrl+C and Ctrl+Z
I wanna ask something regarding Linux shortcut in terminal. If we press ctrl+c, the program will be killed right? I just wonder are we sending SIGTERM or SIGKILL to that program. And also what is the exactly Ctrl+Z do? Is it send SIGSTOP to the program? By sending Ctrl+Z to the program, are we making it become background process?
- 10-27-2008 #2
I believe that Ctrl-C sends SIGINT. Im not sure about the ctrl-Z though. Since the shell catches that signal and puts your program down for a nap, im not sure if you could write a handler for it because im not sure your code will ever see it. But i could be wrong on that.
By the way, ctrl-Z suspends the process. From that point you could move it to the background with the shell command 'bg' or you can bring it back to the foreground by using the 'fg' command. But simply pressing ctrl-Z suspends the process and keeps it from running at all.
- 10-27-2008 #3
Ctrl-C sends the interrupt signal SIGINT. By default, this signal crashes most programs, though some interactive ones handle it as an instruction to stop what they're doing and return to a command prompt.
Ctrl-Z sends SIGSTOP, which freezes the program. To restart it from the same point, you need somehow to send a SIGSTART. This can be done by using the commands fg (to restart it as a foreground process) or bg to restart it in the background."I'm just a little old lady; don't try to dazzle me with jargon!"
- 10-28-2008 #4
@Hazel
Do you mean SIGCONT? Indeed I can make it back to normal by sending it SIGCONT from other terminal.
But that's mean simply send Ctrl+Z doesn't make it become background process right? We must manually use 'bg' syntax to make it background process I thought... But why if we send Ctrl+Z it will listed in 'jobs' ?
- 10-28-2008 #5Oops, thank you! I did mean SIGCONT. That's what happens when you post in a hurry.Do you mean SIGCONT? Indeed I can make it back to normal by sending it SIGCONT from other terminal.
You're right. I just tried it. I started a foreground process, stopped it with ctrl-Z and then sent it a SIGCONT from the same terminal using kill and it restarted as a background job. So it seems you don't actually need to use the bg command after all. You learn something every day!But that's mean simply send Ctrl+Z doesn't make it become background process right? We must manually use 'bg' syntax to make it background process I thought... But why if we send Ctrl+Z it will listed in 'jobs' ?"I'm just a little old lady; don't try to dazzle me with jargon!"


Reply With Quote
