Abackground process is acomputer process that runsbehind 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 aWindows system, a background process is either acomputer program that does not create auser interface, or aWindows service. The former are started just as any other program is started, e.g., viaStart menu. Windows services, on the other hand, are started byService Control Manager. InWindows Vista and later, theyare run in a separate session.[citation needed]
On aUnix orUnix-like system, a background process or job can be further identified as one whoseprocess 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]
InWindows NT family ofoperating systems, a Windows service is a dedicated background process.[5] A Windows service must conform to the interface rules and protocols of theService 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 systemsinclude numerous services which run in context of threeuser accounts:System,Network Service andLocal 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.
BeforeWindows Vista, services installed as "interactive services" could interact with Windowsdesktop and show agraphical user interface. With Windows Vista, however, interactive services becamedeprecated and ceased operating properly, as a result ofWindows Service Hardening.[7][8]
The three principal means of managing Windows services are:
sc.exeA 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 thedaemon function, daemons are disassociated from their parent terminal.[10]
From a Unix command line, a background process can be launched using the "&" operator. Thebg command can resume a suspended job (sendingSIGCONT), running it in the background. Using thefg command will also reconnect standard input its parent terminal, bringing it into the foreground. Thejobs command will list all processes associated with the current terminal and can be used to bring background processes into the foreground.[4][11]
When alogin session ends, via explicit logout or network disconnection, all processes, including background processes, will by default be terminated, to prevent them from becomingorphan processes. Concretely, when the user exits the launching shell process, as part of shutdown it sends ahangup signal (SIGHUP) to all itsjobs, to terminate all the processes in the correspondingprocess group. To have processes continue to run, one can either not end the session, or end the session without terminating the processes. Aterminal 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 thenohup command (telling the process to ignore SIGHUP), or by subsequently runningdisown 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 theinit process (the kernel sets the init process as their parent), and they continue running without a session, now calleddaemons.
In this example running onUnix, thesleep utility was launched into the background. Afterward, theps tool was run in the foreground, where it output the below text. Both were launched from the shell.[12]
PIDTTSTATTIMECOMMAND5465910S0:00.06su(zsh)5470310IN0:00.00-sleep10005485210R+0:00.00-ps-Ubotty-axd
Many newer versions ofsmartphone and PDAoperating 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. OnAndroid, CPU use for background processes may be bounded at 5–10%.[13] Applications on Apple'siOS are limited to a subset of functions while running in the background.[3] On both iOS and Android, background processes, as well as background or unused apps, can be killed by the system if they are using too much memory or too much battery power.[3][13]
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.