In a Unix-like operating system, a process is a program in execution. Kernel identifies a process with a unique id called process id or PID. Whenever a command is issued a new process starts.
In this article, we will discuss different types of processes in Linux or Unix.
Parent and child process
A child process is a process that is created by another process(parent process), a child process is also known as the subprocess. There are two major ways of creating a child process: fork system call which is preferred in Unix like operating systems, the spawn is the preferred way in modern NT kernel of Microsoft Windows.
A process becomes the parent process when it creates one or more subprocess processes.
The init process
The init process is the very first process that gets created when a Linux or Unix machine starts. Every process in Linux has a parent process. So every other process of a system is the children of the init process. It has some special privileges so it cannot be killed it only terminates when the system gets shutdown. It has the process id of 1 which never changes.
Zombie and orphan process
Suppose there are two processes one is the child and the other is the parent process. Two possible scenarios are –
- If the parent process terminated or gets killed before the child process. The child process becomes an orphan process now this will be rescued and adopted by the init process. And the init process becomes the parent process.
- If the child process terminated or gets killed and the parent does not get or able to fetch the termination status. The terminated child process will become a zombie process.
Daemon processes are system-related background processes that often run with the permissions of root and services requests from other processes. Most of the time these processes run in the background and wait for processes. A Daemon process does not require a controlling terminal.
The name of a daemon process normally ends with the letter d. Some of the examples of daemon processes in Unix are −
- crond –This is a job scheduler that runs jobs in the background.
- syslogd – It is the system logger that implements the system logging facility and collects system messages.
- httpd –This is the webserver daemon process.
The processes can also be categorized on the basis of how they are running in a system. Whenever a command executes, it starts a new process. A process can start in two ways –
By default, a process started by a user runs in the foreground. It takes input from the command prompt and displays output to the computer screen. If a foreground process is running, the terminal prevents initiating a new process until the existing one does not get finished.
These are the processes that do not require keyboard input. Another process can be started from the terminal while the previous one is running in the background. To start a background process you should add an ampersand(&) at the end of a command. From a terminal, you can switch between foreground and background processes using