Job control (Unix): Difference between revisions

Content deleted Content added
Control: Organize the best I can so that terms are defined before referenced
Implementation: remove fluff
Line 53:
==Implementation==
{{Unreferenced section|date=February 2020}}
Typically, thea shell keepsmaintains ainformation listabout ofbackground jobs in a '''job table'''. RecallCommand that{{code a job corresponds to a process group, which consists of all the members of a [[pipeline (Unix)|pipeline]] and their descendants. The <code>jobs</code>}} command will listlists the background jobs existing in the jobof table, along with their job number and job state (stopped or running). When aan [[login session |interactive session]] ends when the(i.e. user [[logout |logs out]] (exits the shell, which terminates the ''session leader'' process), the shell process sends signal [[SIGHUP]] to all jobs, and waits for the process groups to endexit before terminating itself.
 
The [[Disown (Unix)|<code>disown</code>]] command can be used to remove jobs from the job table, so that when the session ends the [[child process]] groups are not sent SIGHUP, nor does the shell wait for them to terminate. They thus become [[orphan process]]es, and may be terminated by the operating system, though more often this is used so the processes are adopted by [[init]] (the kernel sets their [[parent process]] to init) and continue executing as [[daemon (computer software)|daemon]]s. Alternatives to prevent jobs from being terminated include [[nohup]] and using a [[terminal multiplexer]].