What are Zombie processes?
Zombie processes are those processes which are killed or completed execution but still shows an entry in the process table.
- The zombie process shows the process with a Z state.
- The zombie process is also known as the defunct process.
- Such kind of processes are dead and not being used for any business or system processing.
- The orphan processes and the zombie processes are different.
- A child process always first becomes a zombie before being removed
- To remove zombies we can use 'kill' command as the SIGCHLD signal can be sent to the parent manually.
Reasons for the zombie processes-
- The issue in the parent program: If the Zombies that exist for more time then it indicates an issue in the parent program
- The issue with child program: The Unix system uncommon decision to not reap children.
- The operating system issue: The bug in the operating system may cause the parent program is no longer running.
Impact of the zombie process-
- No out of memory issue as the zombie process does not consume memory
- The issue with running out of process table entries
What are Orphan processes?
A child process which remains running itself even after its parent process is completed or terminated is called as an orphan process.
- The orphan process is get created unknowingly and unintentionally due to process crash.
- Normally, Unix system tries to protect the orphan process with help of user's shell. The Unix system tries to terminate the child processes by SIGHUP process signal.
- Re-parenting automatically happens in Unix environment. i.e. assigning the parent to the child process. However, it is internal to Unix system
- An orphan process is a computer process whose parent process has finished or terminated, though it remains running itself. Normally special init system process will be the parent for such orphan process. The process is still considered an orphan process as its original parent who created this process is no more exists.
- In some cases, the orphan process is created intentionally. This is to detach the current user's session and let it run in the background, especially when the process is long running. Sometimes such orphan processes are also called a daemon process.
What is the daemon process?
The system related processes which run in the background and often run with the permissions of the root are called daemon processes. In many cases, these daemon processes service requests from other processes.
- A daemon has no controlling terminal.
- The daemon process cannot open /dev/tty.
- e.g If we execute the command "ps -ef" and all daemon processes will have ? for the tty field in the output.
- If we have a program which runs for a long time, it is good idea to make it a daemon and run it in the background.
- Normally, such processes start when the system is bootstrapped
- The daemon processes terminate only when the system is shut down.
Example of daemon process is real world is - printer daemon waiting for print commands.