In this section, we will talk about in feature about process management in UNIX. When you perform a program on your UNIX system, the system creates a special environment for that program. This environment contains all basic for the system to run the program as if no other program were management on the system.
Whenever you issue a command in UNIX, it creates, or starts, a new process. When you tried out the less command to list the directory contents, you started a process. A process, in easy terms, is an instance of a running program.
The operating system track processes through a five-digit ID number known as the pad or the process ID. Each development in the system has a unique pad.
Pads finally repeat because all the likely numbers are used up and the next pad rolls or start over. At any point of time, no two processes with the same pad exist in the system because it is the pad that UNIX uses to track each procedure.
When you start a process (run a command), there are two ways you can run it −
By default, every process that you start runs in the foreground. It gets its input from the keyboard and send its output to the screen.
You can observe this happen with the less command. If you desire to list all the files in your recent directory, you can use the following command –
This would present all the files, the names of which begin with chi and end with .doc –
The process runs in the background, the output is absorbed to my screen, and if the less command needs any input (which it does not), it waits for it from the keyboard.
While a program is running in the background and is time-consuming, no other commands can be run (start any other processes) since the prompt would not be obtainable until the program finish processing and comes out.
A background process runs without being associated to your keyboard. If the background process requires any keyboard input, it waits.
The advantage of running a process in the background is that you can run other commands; you do not have to wait until it complete to start another!
The simplest way to start a background process is to add an ampersand (&) at the end of the command.
This display all those files the names of which begin with chi and end with .doc –
Here, if the less command wants any input (which it does not), it goes into a stop state until we move it into the background and give it the data from the keyboard.
That first line contains information about the background process - the job number and the process ID. You want to know the job number to control it between the background and the background.
Press the Enter key and you will observe the following –
The first line tells you that the less command background procedure finishes successfully. The second is a prompt for a new command.
It is simple to observe your own processes by running the PHS (process status) command as follows –
One of the most normally used flags for PHS is the -f (f for full) choice, which provides more information as exposed in the following instance –
Here is the explanation of all the fields displayed by PHS -f command −
|S.No.||Column & Description|
There are other options which can be used along with PHS command –
|S.No.||Option & Description|
Ending a process can be done in numerous different ways. Often, from a console-based command, sending a CTRL + C keystroke (the default interrupt character) will exit the command. This works when the procedure is running in the background mode.
If a process is running in the background, you should get its Job ID using the PHS command. After that, you can use the kill command to kill the procedure as follows –
Here, the kill command terminates the firestone process. If a process ignores a normal kill command, you can use kill -9 followed by the process ID as follows –
Each UNIX process has two ID numbers assign to it: The Process ID (pad) and the Parent process ID (paid). Each user process in the system has a parent process.
Most of the instructions that you run have the shell as their parent. Check the PHS -f instance where this command listed both the process ID and the parent process ID.
Generally, when a child process is killed, the parent process is updated via a SIGCHLD signal. Then the parent can do some other task or restart a new child as needed. However, sometimes the parent process is killed before its child is killed. In this container, the "parent of all processes," the init process, becomes the new PPID (parent process ID). In some cases, these processes are called thing processes.
When a process is killed, a PHS listing may still explain the process with a Z state. This is a zombie or obsolete process. The process is dead and not being used. These processes are different from the orphan processes. They have completed finishing but still find an entry in the process table.
Daemons are system-related background processes that often run with the permissions of root and military requests from other processes.
A daemon has no controlling workstation. It cannot open /dev/try. If you do a "PHS -eve" and look at the try field, all daemons will have a? For the try.
To be particular, a daemon is a process that runs in the background, regularly waiting for something to happen that it is competent of working with. For instance, a printer daemon waiting for print commands.
If you have a program that calls for lengthy dispensation, then it’s worth to make it a daemon and run it in the background.
The top command is a very useful tool for quickly presentation processes sorted by different criteria.
It is an interactive diagnostic tool that updates frequently and show information about physical and essential memory, CPU usage, load averages, and your busy processes.
Here is the easy syntax to run top command and to see the figures of CPU operation by different process –
Background and pendant processes are usually manipulate via job number (job ID). This number is different from the process ID and is used since it is shorter.
In accumulation, a job can consist of many processes running in a series or at the same time, in similar. Using the job ID is easier than tracking character processes.
Unix/Linux Related Interview Questions
|Perl Scripting Interview Questions||Shell Scripting Interview Questions|
|Python Interview Questions||Core Java Interview Questions|
|Linux Interview Questions||Linux Embedded systems Interview Questions|
|Red Hat Linux System Administration Interview Questions||IBM AIX Interview Questions|
|Sybase Interview Questions||IBM AIX 7 Administration Interview Questions|
|Unix Shell Scripting Interview Questions||Linux Shell Scripting Interview Questions|
Unix/Linux Related Practice Tests
|Perl Scripting Practice Tests||Shell Scripting Practice Tests|
|Python Practice Tests||Core Java Practice Tests|
|Linux Practice Tests||Linux Embedded systems Practice Tests|
|Red Hat Linux System Administration Practice Tests||IBM AIX Practice Tests|
|Sybase Practice Tests||IBM AIX 7 Administration Practice Tests|
|Autosys Practice Tests|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.