Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Fg built-in

The fg resumes a suspended job in the foreground.

Synopsis

fg [job_id]

Description

See Job control for an overview of job control in yash-rs. The built-in brings the specified job to the foreground and resumes its execution by sending the SIGCONT signal to it. The built-in then waits for the job to finish (or suspend again).

If the resumed job finishes, it is removed from the job list. If the job gets suspended again, it is set as the current job.

Options

None.

Operands

Operand job_id specifies which job to resume. See Job IDs for the operand format. If omitted, the built-in resumes the current job.

Standard output

The built-in writes the selected job name to the standard output.

Errors

It is an error if:

  • the specified job is not found,
  • the specified job is not job-controlled, that is, job control was off when the job was started, or
  • job control is off in the current shell environment.

Exit status

The built-in returns with the exit status of the resumed job. If the job is suspended, the exit status is as if the job had been terminated with the signal that suspended it. (See also Suspending foreground jobs.)

On error, it returns a non-zero exit status.

Examples

See Job control.

Compatibility

Many implementations allow omitting the leading % from job IDs and specifying multiple job IDs at once, though this is not required by POSIX and not yet supported in yash-rs.