When you start a process (run a command), there are two ways you can run it: Foreground Processes Background Processes Foreground Processes: By default, every process that you start runs in the foreground. It gets its input from the keyboard and sends its output to the screen. Background Processes: A background process runs without being connected 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 completes to start another! The simplest way to start a background process is to add an ampersand ( &) at the end of the command. Stopping Processes: If a process is running in background mode then first you would need to get its Job ID using ps command and after that you can use kill command to kill the process as follows: $ps -f UID PID PPID C STIME TTY TIME CMD amrood6738 3662 0 10:23:03 pts/6 0:00 first_one amrood6739 3662 0 10:22:54 pts/6 0:00 second_one amrood3662 3657 0 08:10:53 pts/6 0:00 -ksh amrood6892 3662 4 10:51:50 pts/6 0:00 ps -f $kill 6738 Terminated Here kill command would terminate first_one process. If a process ignores a regular kill command, you can use kill -9 followed by the process ID as follows: $kill -9 6738 Terminated Question Execute and document the commands to: Run a process in background Run a process in foreground Call the process from background to foreground

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

When you start a process (run a command), there are two ways you can run it:

  • Foreground Processes

  • Background Processes

Foreground Processes:

By default, every process that you start runs in the foreground. It gets its input from the keyboard and sends its output to the screen.

Background Processes:

A background process runs without being connected 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 completes to start another!

The simplest way to start a background process is to add an ampersand ( &) at the end of the command.

Stopping Processes:

If a process is running in background mode then first you would need to get its Job ID using ps command and after that you can use kill command to kill the process as follows:

$ps -f

UID PID PPID C STIME TTY TIME CMD amrood
6738 3662 0 10:23:03 pts/6 0:00 first_one amrood
6739 3662 0 10:22:54 pts/6 0:00 second_one amrood
3662 3657 0 08:10:53 pts/6 0:00 -ksh amrood
6892 3662 4 10:51:50 pts/6 0:00 ps -f

$kill 6738

Terminated

Here kill command would terminate first_one process. If a process ignores a regular kill command, you can use kill -9 followed by the process ID as follows:

$kill -9 6738

Terminated

Question

Execute and document the commands to:

  1. Run a process in background

  2. Run a process in foreground

  3. Call the process from background to foreground

Expert Solution
steps

Step by step

Solved in 2 steps with 10 images

Blurred answer
Knowledge Booster
Avoiding deadlock
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage