Process Control

Process Control

The main purpose of the shell is to serve as an intermediary between you and various resources of your operating system. When you type in a command line, the shell uses its various substitution and aliasing mechanisms to decide exactly what it is you want done, constructs a command line, and submits the line to the kernel. By default, you will be asking for some command to be run immediately at the highest available priority. Again by default, your shell will wait until the request has been resolved and communicate the results to you.

The default behavior may not be what you want. The commands described in this section enable you to modify the priority and resources used by an executing process.

Foreground vs. Background Processes

If you do not want the shell to suspend its execution until a child process completes, you may request that that process be run in the background. This is accomplished by the simple expedient of appending an ampersand '&' to the command line:

> somecommand &

When you set a command to run in the background, the shell assigns a job number to the process, prints that number out, and immediately prompts you for more input. When the job completes, the shell displays any results and the associated job number. If you are runing a job and wish to do something else, you may hit the suspend key (usually '^Z'), which sends a STOP signal to the current job.

Jobs in the background may be displayed with the jobs command or manipulated with the fg and bg commands.

exec

If for some reason you wish to replace your current shell with some other program, you may use the exec command. Exec is essentially a front end for the exec() system call, which completely replaces the currently executing process with some other process. Calls to exec will never return effectively terminating your current login session and should be used with caution.

Process Priority

The kernel assigns each running process a priority value between -19 (highest) and 20 (lowest) for use in computing which process gets next crack at system resources. The default value is 0. Users who are not root are only permitted to request a lower priority for their child processes. The root user can assign higher priorities to its child processes.

Process priority is manipulated by means of the nice and renice commands. Both commands affect process priority. Nice is used when a process is created, renice is used on an existing process.

 



Linux Desk Reference
Linux Desk Reference (2nd Edition)
ISBN: 0130619892
EAN: 2147483647
Year: 2000
Pages: 174
Authors: Scott Hawkins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net