Key Notes

What is a process?

Everything (except the kernel) on a Linux system runs in the context of a process. Process can be loosely defined as a running program. Every process on a Linux system has a unique Process ID (PID). Users and programs use this PID to communicate with the process.

The key command to find out various processes and their properties on a Linux system is ps.

E.g. the following command shows all processes currently running on the system:

> ps -e

 

What is a Signal?


Signals are mechanisms to communicate with processes. E.g. when a user or a program wants to terminate a process, it will send a specific signal (SIGTERM, sometimes referred to as just TERM) to that process.

The command used to send a signal to a process is called kill. The kill command can send any specified signal to a process. If no signal is specified it sends the SIGTERM signal (hence the name "kill"). But note that killing processes is not the sole function of the command kill; it can be used to send any of the signals defined on the system.

SIGTERM (Signal number 15) signal is used to gracefully kill a process. If a process is hanging in a bad state and it won't go away even after sending it a SIGTERM, you can send it the SIGKILL (Signal number 9) signal, which is a forced shutdown of a process. Note that with SIGKILL the process will not have opportunity to clean up any system resources it was using (e.g. temporary files etc.). For example:

# kill -9 6041

(Will forcefully kill process with PID 6041)

Generally system administrators will find the PID of the process to which they want to send the signal by using the Pscommand, and then use the kill command to send a signal to that PID. But it is also possible to send a signal to process by its name. For example:

> killall httpd

(will send SIGTERM to all httpd processes)

Quick Test