In: Computer Science
Why is it important to learn the various signals associated with
the kill command?
Well if you are using windows platform then you might have encountered with the message shown below:
After this we directly click on END PROCESS button to stop the process, But if you are Unix/ Linux users you will never come up with this message i.e. if you are unable to run any program in Unix/Linux platform you have to stop it by yourself to stop that particular process by using some commands. To stop that process you need use Kill command.
Kill command is one of the powerful commands used in Unix. It is used to :
1. Terminate the process
2. Send a specific signal to the process.
Now the question arises what is a signal. The signal can be defined as an interrupt to a process.
Syntax of Kill Command:
e.g if we write a command on the command prompt as shown below:
This command will stop the process with id 7640 (To check the id of the process use Ps command). Now when the interrupt occurs what happened actually in the system? These are the signal which take part when the interrupt occurs. It generates a signal to the process to do a respected action against the process. Below mentioned are some of the signals generated when the interrupt occurs:
These above list of signals are most commonly used signals during interrupt.
Lets take a example of Command Number 15 Signal Name SIGTERM (highlighted above). When we run kill command internally the SIGTERM sends a signal to the process and the purpose of this SIGTERM command is to Terminate the process or ignores. i.e it may kill/ stop the process or ignores that (see the purpose in above diagram). So , in order to forcefully stop that process we can use one more signal called as SIGKILL, the main purpose of this command is to forcefully kill the process and does not ignores the process termination. Therefore it is very important to know the various signals associated with the Kill command.
Syntax to use these signals:
$ kill -9 1605
Here 9 is the number associated with SIGKILL signal and 1605 is the process id. i.e This command will kill the process with id 1605.
$ kill -15 0516
This above command may kill or ignores the process with id 0516 , because 15 is the number for signal SIGTERM.
Thus, it is very important to know the functionality of each signal associated with the kill command for better execution.