Process Terminology – What is a Background Process?

processterminology

Here is a common definition of a background process:

"A background process is a program that is running without user input. A number of background processes can be running on a multitasking operating system, such as Linux, while the user is interacting with the foreground process Some background processes, such as daemons, for example, never require user input. Others are merely in the background temporarily while the user is busy with the program presently running in the foreground. So that other process can be sleeping and taking up swap space, until activated, which thus makes it currently a background process."

Given that definition, wouldn't that make a process like apache2 a background process since it never interacts with user input in terminal? And wouldn't that consider most process background processes, since most processes running on a system do not deal with user input in the terminal? Oddly enough, I personally wouldn't consider apache2 a background process since a user does interact with it through http requests (just not a terminal).

Best Answer

A foreground process does not necessitate user interaction. You can do

cp very_large_file destination

and this would block your terminal until the copy finished and would be considered a foreground process with no user interaction. The point here being whether the process blocks the execution of other processes until it terminates.

Two ways you can make a foreground process into a background one:

1- Adding an ampersand (&) at the end of your command line:

cp very_large_file destination &

2- Stopping a foreground process then bringing it into the background:

cp very_large_file destination

CTRL+Z

bg

Now apache2 would definitely count as a background process: yes you can interact with it via http requests but it simply listens on port 80 (by default) waiting for such a request: it does not block the system until the user makes a request.

And why do you take issue at most processes being considered background processes? This is indeed normal in a "multi-tasking operating system".

Related Question