Background process explained

A background process is a computer process that runs behind the scenes (i.e., in the background) and without user intervention.[1] Typical tasks for these processes include logging, system monitoring, scheduling,[2] and user notification.[3]

On a Windows system, a background process is either a computer program that does not create a user interface, or a Windows service. The former are started just as any other program is started, e.g., via Start menu. Windows services, on the other hand, are started by Service Control Manager. In Windows Vista and later, they are run in a separate session.

On a Unix or Unix-like system, a background process or job can be further identified as one whose process group ID differs from its terminal group ID (TGID). (The TGID of a process is the process ID of the process group leader that opened the terminal, which is typically the login shell. The TGID identifies the control terminal of the process group.) This type of process is unable to receive keyboard signals from its parent terminal, and typically will not send output to that terminal.[4] This more technical definition does not distinguish between whether or not the process can receive user intervention. Although background processes are typically used for purposes needing few resources, any process can be run in the background, and such a process will behave like any other process, with the exceptions given above.[1]

Windows services

See main article: article and Windows service. In Windows NT family of operating systems, a Windows service is a dedicated background process.[5] A Windows service must conform to the interface rules and protocols of the Service Control Manager, the component responsible for managing Windows services.[6]

Windows services can be configured to start when the operating system starts, and to run in the background as long as Windows runs. Alternatively, they can be started manually or by an event. Windows NT operating systems include numerous services which run in context of three user accounts: System, Network Service and Local Service. These Windows components are often associated with Host Process for Windows Services: svchost.exe. Since Windows services operate in the context of their own dedicated user accounts, they can operate when a user is not logged on.

Before Windows Vista, services installed as "interactive services" could interact with Windows desktop and show a graphical user interface. With Windows Vista, however, interactive services became deprecated and ceased operating properly, as a result of Windows Service Hardening.[7] [8]

The three principal means of managing Windows services are:

  1. Services snap-in for Microsoft Management Console
  2. sc.exe
  3. Windows PowerShell

Daemon

See main article: article and Daemon (computing). A daemon is a type of background process designed to run continually in the background, waiting for event(s) to occur or condition(s) to be met.[9] When launched with the daemon function, daemons are disassociated from their parent terminal.[10]

Background jobs in Unix

See main article: article and Job control (Unix). From a Unix command line, a background process can be launched using the "&" operator. The bg command can resume a suspended job (sending SIGCONT), running it in the background. Using the fg command will also reconnect standard input its parent terminal, bringing it into the foreground. The jobs command will list all processes associated with the current terminal and can be used to bring background processes into the foreground.[11]

When a login session ends, via explicit logout or network disconnection, all processes, including background processes, will by default be terminated, to prevent them from becoming orphan processes. Concretely, when the user exits the launching shell process, as part of shutdown it sends a hangup signal (SIGHUP) to all its jobs, to terminate all the processes in the corresponding process group. To have processes continue to run, one can either not end the session, or end the session without terminating the processes. A terminal multiplexer can be used to leave a session running but detach a virtual terminal from it, leaving processes running as child processes of the session; the user can then reattach session later. Or, termination can be prevented by either starting the process via the nohup command (telling the process to ignore SIGHUP), or by subsequently running disown with the job id, which either removes the job from the job list entirely, or simply prevents SIGHUP from being sent. In the latter case when the session ends, the child processes are not terminated, either because they are not sent SIGHUP or because they ignore it, and thus become orphan processes, which are then adopted by the init process (the kernel sets the init process as their parent), and they continue running without a session, now called daemons.

Example

In this example running on Unix, the sleep utility was launched into the background. Afterward, the ps tool was run in the foreground, where it output the below text. Both were launched from the shell.[12] PID TT STAT TIME COMMAND54659 10 S 0:00.06 su (zsh)54703 10 IN 0:00.00 - sleep 100054852 10 R+ 0:00.00 - ps -U botty -axd

Smartphones

Many newer versions of smartphone and PDA operating systems now include the ability to start background processes. Due to hardware limits, background processes on mobile operating systems are often restricted to certain tasks or consumption levels. On Android, CPU use for background processes may be bounded at 5 - 10%.[13] Applications on Apple's iOS are limited to a subset of functions while running in the background.[3] On both iOS and Android, background processes can be killed by the system if they are using too much memory.[3] [13]

See also

Notes and References

  1. Web site: What is an Operating System?, Processes. 14 November 2010. The Linux Tutorial. 15 August 2020. https://web.archive.org/web/20200815081900/http://www.linux-tutorial.info/modules.php?name=MContent&pageid=3. dead.
  2. Book: Oracle Database Concepts, 10g Release 1. B10743-01. December 1993. Michele Cyran. Oracle Corporation. 12 November 2010. 2 March 2013. https://web.archive.org/web/20130302105539/http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10743/process.htm. dead.
  3. Web site: How Multitasking Works in the New iPhone OS 4.0. 8 April 2010. Jesus Diaz. 14 November 2010. Gizmodo. https://web.archive.org/web/20101102204211/http://gizmodo.com/5512656/how-multitasking-works-in-the-new-iphone-os-40. 2 November 2010. live.
  4. Book: GNU Bash Reference Manual, Edition 4.1, Job Control Basics. 23 December 2009. Free Software Foundation, Inc. 10 November 2010. https://web.archive.org/web/20101203065719/https://www.gnu.org/software/bash/manual/bashref.html. 3 December 2010. live.
  5. Web site: Services overview. Microsoft TechNet. Microsoft. 29 March 2013.
  6. Web site: Services . . Microsoft . 29 March 2013.
  7. Web site: New Elevation PowerToys for Windows Vista. TechNet Magazine. Microsoft. 21 June 2013. June 2008. The service CmdAsSystem is configured as interactive whose support is being deprecated. The service may not function properly. The problem is that this script tries to create and start an interactive service. Interactive services will not function correctly due to Session 0 Isolation in Windows Vista..
  8. Web site: Services in Windows. MSDN. Microsoft. 21 June 2013. 18 October 2010.
  9. Book: The Jargon File, version 4.4.8, "daemon" . Eric S. Raymond . 1 October 2004 . 10 November 2010 . https://web.archive.org/web/20101103102331/http://catb.org/~esr/jargon/html/D/daemon.html . 3 November 2010 . live .
  10. Book: Linux User's Manual, "daemon". raf. 12 June 2010. 10 November 2010. https://web.archive.org/web/20101021032110/http://libslack.org/daemon/manpages/daemon.1.html. 21 October 2010. live.
  11. Web site: Background Processes in Unix/Linux. Åke Nordlund. 7 February 2007. 10 November 2010. https://web.archive.org/web/20120213174734/http://www.astro.ku.dk/comp-phys/tutorials/background.shtml. 13 February 2012. dead.
  12. Web site: POSIX "ps". IEEE Std 1003.1, 2004 Edition.
  13. Web site: Giz Explains: How Multitasking Works on a Phone. Matt Buchanan. 2010-04-29. Gizmodo. 14 November 2010. https://web.archive.org/web/20101017123040/http://gizmodo.com/5527407/giz-explains-how-multitasking-works-on-a-phone. 17 October 2010. live.