Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Background process
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Background jobs in Unix== {{main article|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.<ref name="bash" /><ref>{{cite web|url=http://www.astro.ku.dk/comp-phys/tutorials/background.shtml|title=Background Processes in Unix/Linux|author=Γ ke Nordlund|date=7 February 2007|accessdate=10 November 2010|archive-url=https://web.archive.org/web/20120213174734/http://www.astro.ku.dk/comp-phys/tutorials/background.shtml|archive-date=13 February 2012|url-status=dead}}</ref> 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 process]]es. Concretely, when the user exits the launching shell process, as part of shutdown it sends a ''hangup'' signal ([[SIGHUP]]) to all its [[Job control (Unix)|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 (Unix)|<code>disown</code>]] 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 ''[[Daemon (computer software)|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.<ref>{{cite web |url=http://pubs.opengroup.org/onlinepubs/7999959899/utilities/ps.html|title=POSIX "ps"|work=IEEE Std 1003.1, 2004 Edition}}</ref> <syntaxhighlight lang="bash"> PID TT STAT TIME COMMAND 54659 10 S 0:00.06 su (zsh) 54703 10 IN 0:00.00 - sleep 1000 54852 10 R+ 0:00.00 - ps -U botty -axd </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)