There are seven different types of process in Linux which are:
- Init Process
- Parent Process
- Child Process
- Interactive or Foreground Process
- Background Process or Daemon Process
- Zombie Process
- Orphan Process
- It is the first process to be created when the Linux machine boots up.
- It is a daemon process that continues to run until Linux is shut down that is it cannot be killed, if a signal is sent to the Init process, it is simply discarded.
- Init is started by the kernel during the booting process; a kernel panic will occur if the kernel is unable to start it or the init process calls exit() itself.
- It will adopt all the orphaned processes.
- Since Init process is the ancestor process of all the other processes, and killing them would make all the process as an orphan and no process would be left to re-parent them to.
- The PID of Init process is 1 and PPID is 0.
- A parent process is a process that has created another process called the child process.
- In Linux, every process has a parent process except the Init and a few other kernel processes.
- It is the process created by a process.
- In Linux, all the processes except the Init process are children of a process.
Diag-1: Process ID and Parent Process ID
Interactive or Foreground Process:
- It is the process that is under the control of the users through a terminal session.
- Such a process needs constant instruction from end-user while it is processing.
- Once the terminal is ended, even the process is killed and hence such a process can be killed accidentally too.
Daemon or Background Process:
- These are the process that runs independently of any terminal session.
- A process which does not needs any interaction with the user and need to run longer is made as a background process.
- Syntax: process_name &>/dev/null &
- This will redirect the output of the command to nowhere and can be changed for redirecting to the proper location.
- Typically, daemon names end with the letter d: for example, syslogd is the daemon that implements the system logging facility and sshd is a daemon that services incoming SSH connections.
- The daemon process is a process orphaned intentionally.
Common advantages associated with the Daemon process are:
- log out without losing the service (which saves some resources)
- do not risk to loosing the service from an accidental ctrl-c
- does not offer a minor security risk from someone accessing the terminal, hitting ctrl-c and taking our session
- A process is considered to be an orphan if its parent process does not exist.
- All the orphan processes are re-parented by the Init process.
- Orphan processes take resources while they are in the system, and can potentially leave a server starved for resources. Having too many Orphan processes will overload the init process and, can hang up a Linux system
Reason for Orphan Process:
- A process can be orphaned either intentionally or unintentionally. Sometimes a parent process exits/terminates or crashes leaving the child process still running, and then they become orphans.
- Also, a process can be intentionally orphaned just to keep it running. For example, when we need to run a job in the background which does not need any manual intervention and going to take a long time, then we detach it from the user session and leave it there.
- Same way, when we need to run a process in the background for infinite time, we need to do the same thing. Processes running in the background like this are known as a daemon process.
- Zombie or a defunct process is a process that has completed its execution but still has an entry in the parent process table.
- When the child process ends, it must release all the resources so that they can be used by other processes.
- The child process sends a SIGCHILD signal to the parent process indicating that the child process has terminated and the parent should read the exit status and remove the entry from its table.
- If the parent process does not clean the entry from its table, it is referred as the Zombie process.
- To remove zombies from a system, the SIGCHILD signal can be sent to the parent manually, using the kill command.
- If the parent process still refuses to reap the zombie, the next step would be to remove the parent process. When a process loses its parent, init becomes its new parent. Init periodically executes the wait system call to reap any zombies with init as parent
- Process vs program
- Sections of a process
- States of a process
- process Control Block(PCB)
- Attributes of a process
- Context Switching
- Termination of a process
Categories: Operating system (OS)
Leave a Reply