Job control (Unix): Difference between revisions

Content deleted Content added
I used 'unix-based' to mean 'unix and unix-like'
Control: Organize the best I can so that terms are defined before referenced
Line 31:
 
==Control==
[[POSIX]] specifies the interface to job control {{endash}} modeled on the Korn shell.<ref>{{man|cu|bg|SUS}}; {{man|cu|fg|SUS}}.</ref>. The commands are typically implemented as [[shell builtin]]s; not separate [[computer program |programs]].
[[POSIX]] specifies the interface to job control {{endash}} modeled on the Korn shell.<ref>{{man|cu|bg|SUS}}; {{man|cu|fg|SUS}}.</ref>. If a command line ends with {{code|&}}, then the job starts in the background. Command {{code|fg}} (short for foreground) causes a background job to move to the foreground; either the job specified or the one most recently added to 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 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> The foreground job can be paused by pressing {{keypress|Control|Z}} and when paused it can be resumed in the background via command {{code|bg}} (short for background). Command {{code|jobs}} reports information about each background job including ID, command line and running status.
 
; Start in background
The commands are typically implemented as [[shell builtin]]s; not separate [[computer program |programs]].
If a command line ends with {{code|&}}, then the job starts in the background.
 
; Pause foreground job
The foreground job can be paused by pressing {{keypress|Control|Z}}. In this state, a job can be resumed in the background via {{code|bg}} or resumed in the foreground via {{code|fg}}.
 
; Command {{code|fg}}
Command {{code|fg}} (short for foreground) causes a background job to move to the foreground; either the job specified or the one most recently added to the background if none specified.
 
; Command {{code|wait}}
Command [[wait (command)|<code>wait</code>]] pauses the interactive session until the specified background jobs complete or for all background jobs of the active shell if none 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>
 
; Command {{code|bg}}
Command {{code|bg}} (short for background) moves the paused foreground job to the background and resumes it.
 
; Command {{code|jobs}}
Command {{code|jobs}} reports information about each background job including ID, command line and running status.
 
==Implementation==