The processes are running programs. Each software can start one or more processes that will have to be loaded into main memory for processing by the CPU. Sometimes a process can be subdivided into so-called LWPs or lightweight processes, that is, into threads, threads or threads, whatever you want to call them. When all the threads of a process have been executed, then the process is finished.
Made that introduction, say that processes in Unix environments are identified by an ID and can have various states. That ID or identifier is a number assigned to said process to be able to track it. You can easily know the PID of a process with the ps tool, htop, among other tools. And you can also see information about its status.
The States in which a process can be in Linux are:
- Running: the process is running.
- Sleeping: the process is sleeping, waiting for an event to happen that wakes it up and continues its execution.
- Terminating: the process is terminated or dead.
- Device I / O - I / O device processes that cannot be interrupted.
- Zombie: when a child process terminates before its parent process, the child information is kept until the parent terminates as well. The son is really dead or finished, but cannot be destroyed to free up resources. It doesn't really take up CPU time, but it does take up space in the process table.
One way of sending signals to the processes so that they go to one state or another is through the kill command. If you use the kill -l command you will see the list of signals that you can send. The most typical is to send a KILL signal to a process to kill it. For example:
kill -l kill -9 <PID>
Signal 9 or SIGKILL directly kills the process signaled by PID without checking the status. Instead, SIGTERM will terminate the process only in certain circumstances, since it does check the status of the process to which the signal is sent and if it is not safe, the signal will be ignored.
Well, having said all that, tools like ps have a column that shows the STAT or status of the process. If you look at that column, the initial of the state it is in appears. For example, S for sleeping, or Z for zombie, etc. You may check if you have zombie processes or not on your system with the following command:
ps aux | grep 'Z'
In my case, there was one with PID 6393. And for kill zombie processes, you can use the following command: