Content deleted Content added
Stevebroshar (talk | contribs) Move up what a job is |
Stevebroshar (talk | contribs) Organize so that we define terms before using them |
||
Line 1:
{{Short description |Control of jobs by a Unix shell}}
{{About |job control on a Unix system |the general computing term |job control (computing){{!}}job control}}
In a [[Unix]] or [[Unix-like]] [[operating system]], '''job control''' refers to controlling a [[process group]] as a [[job (computing)|job]] via a [[Unix shell| shell]].<ref>IEEE Std 1003.1-2001, [http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_201 Section 3.201, Job]</ref> Control features include suspend, resume, and terminate, and more advanced features can be performed by sending a [[signal (computing)|signal]] to a job. Job control allows a user to manage processing in the Unix-based [[multiprocessing]] environment, and is distinct from [[job control (computing)|general computing job control]].
A job encompasses all of the processes that start for the handling of a shell [[command line]]. A simple command line my start just one process, but a command line may result in multiple processes since a process can create [[child
By default, a job runs in the foreground. The user enters a command line and interacts with the processes (since they can access the [[standard streams |interactive input and output]]) but cannot issue another command until the current job terminates. Many operations (i.e. listing files) are relatively quick so the user can wait for a response with little down time and some operations (i.e. editing) require interaction that is only possible via a foreground job. But, if interaction is not required and the operation prevents access to the shell for a long time, the user may want to run it in the background. Job control allows the user to run a job in the background {{endash}} where the processes cannot access interactive input and output but the user can perform other foreground operations.
[[POSIX]] specifies job control commands {{endash}} modeled after the Korn shell job control commands.<ref>{{man|cu|bg|SUS}}; {{man|cu|fg|SUS}}.</ref>. Command {{code|bg}} resumes the foreground job paused via {{keypress|Control|Z}} as a background job. Command {{code|fg}} causes the background job to run in the foreground; either the job specified or the one most recently sent the background if none specified. Command [[wait (command)|<code>wait</code>]] pauses the interactive session for the specified background jobs to complete or for all background jobs of the active shell if none is specified.<ref>{{cite web | last=Kerrisk| first=Michael |date=Feb 2, 2025 |title=wait(1p) — Linux manual page |website=man7.org |url=https://www.man7.org/linux/man-pages/man1/wait.1p.html |publisher= |access-date=May 13, 2025}} </ref>▼
▲[[POSIX]] specifies job control
Job control was first implemented in the [[C shell]] by Jim Kulp,<ref>
Line 23 ⟶ 25:
The [[KornShell]], developed at [[Bell Labs]], adopted it and it was later incorporated into the SVR4 version of the [[Bourne shell]], and exists in most modern Unix shells.
==
A job
▲A job can is identified by a [[Handle (computing)|handle]]{{efn|A job ID is an abstract reference by the shell to a resource (a process group) managed externally, by the operating system, hence is a handle.}} called the ''job control job ID'' or simply ''{{visible anchor|job ID}}'', which is used by [[shell builtin]]s to refer to the job. A job ID begins with the <code>%</code> character; <code>%n</code> identifies job ''n'', while <code>%%</code> identifies the current job. Other job IDs are specified by [[POSIX]].<ref>IEEE Std 1003.1-2001, [http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_203 Section 3.203, Job Control Job ID]</ref> In informal usage the number may be referred to as the "job number" or "job ID", and Bash documentation refers to the (%-prefixed) job ID as the ''jobspec.''<ref>[https://www.gnu.org/software/bash/manual/html_node/Job-Control-Basics.html#Job-Control-Basics 7.1 Job Control Basics]</ref>
Job control and IDs are typically only used in an interactive shell. In scripting, PGIDs are used instead, as they are more precise and robust, and indeed job control is disabled by default in a bash script.
|