What is a signal ?
Signal is a notification, a message sent by either operating system or some application to your program (or one of its threads).
ex: SIGINT that I already mentioned, tells your program that someone tries to interrupt it with CTRL-C.
from the command prompt you can list all the signal types like :
In this Signal Number 1,2,9 and 15 are the most used by the system administrator.
Open terminal and type :
1.Enter sleep command with a delay time (10000) running in the background (&)
Here you can see the result [1] 2486 which is the Job No and the Process ID.
2.Enter Kill command with the process ID .
When you check the active Process with the command ps -aux | grep sleep.we can see the sleep command is terminated.Here you can see the sigterm command executed default.
if you want to kill the command.then:
we can see that after giving the command :
#Kill - 9 2549
The sleep command was killed. Signal (-9) is SIGKILL.
Control signals in Bash
Signal is a notification, a message sent by either operating system or some application to your program (or one of its threads).
ex: SIGINT that I already mentioned, tells your program that someone tries to interrupt it with CTRL-C.
from the command prompt you can list all the signal types like :
You’ll see that each signal type has a name (such as SIGINT, or just
INT) and a number (2 in this case.) Out of a total of 64 signal types shown by kill
-l , you’ll probably only need to deal with half a dozen or so,
Signal name | Signal value | Effect |
---|---|---|
SIGHUP | 1 | Hangup |
SIGINT | 2 | Interrupt from keyboard |
SIGKILL | 9 | Kill signal |
SIGTERM | 15 | Termination signal |
SIGSTOP | 17,19,23 | Stop the process |
Open terminal and type :
1.Enter sleep command with a delay time (10000) running in the background (&)
Here you can see the result [1] 2486 which is the Job No and the Process ID.
2.Enter Kill command with the process ID .
When you check the active Process with the command ps -aux | grep sleep.we can see the sleep command is terminated.Here you can see the sigterm command executed default.
if you want to kill the command.then:
we can see that after giving the command :
#Kill - 9 2549
The sleep command was killed. Signal (-9) is SIGKILL.
Control signals in Bash
Ctrl+C | The interrupt signal, sends SIGINT to the job running in the foreground. |
Ctrl+Y | The delayed suspend character. Causes a running process to be stopped when it attempts to read input from the terminal. |
Ctrl+Z | The suspend signal, sends a SIGTSTP to a running program, thus stopping it and returning control to the shell. |
No comments:
Post a Comment