jobs(C)


jobs -- display status of jobs

Syntax

jobs [ -l | -p ] [ job_ID ... ]

Description

jobs displays the status of jobs that were started in the current shell. If a list of job IDs is specified, jobs will only report on these.

A job_ID may be specified in any of the following forms:


pid
Specifies the process ID of the process group leader of a job (found using the -p option).

%n
Specifies a job by a decimal number n, its identification number in the current shell.

%+
%%
Specify the current job.

%-
Specifies the job that would become the current job if the present one were to exit.

%string
Specifies the job whose command begins with string.

%?string
Specifies the job whose command contains string.
jobs accepts either of the following options:

-l
Prints a long status listing for each job as shown in the ``Output formats'' section.

-p
Displays only the process IDs for the process group leaders of the specified jobs.
By default, jobs reports the status of all stopped jobs, all running background jobs, and all jobs where a status change has not been reported to the shell.

Output formats

Output from jobs has the form:

[job_ID] current status command

Output for the -l option has the form:

[job_ID] current group_ID status command

Output for the -p option has the form:

process_ID

The output fields have the following meanings:


job_ID
The identification number of the job in the current shell.

process_ID
The process IDs of the process group leaders for each job.

current
May be set to one of the following:

+
Indicates the job that would be considered the current job by the bg(C), fg(C), kill(C), or wait(C) commands; select this job by specifying %% or %+.

-
Indicates the job that would become the current default job if the present one were to exit; specify this job using %-.

<Space>
All jobs other than the current and next to current jobs.

group_ID
The process ID of the process group leader; subsequent lines display processes in the same process group showing only their process ID and command.

status
A string that shows the state of the process:

Done
The job completed with an exit value of 0.

Done(code)
The job completed normally with an exit value of code (a decimal number).

Running
The job has not exited or been suspended by a signal.

Stopped
Stopped (SIGTSTP)
The job was suspended by the SIGTSTP signal.

Stopped (SIGSTOP)
The job was suspended by the SIGSTOP signal.

Stopped (SIGTTIN)
The job was suspended by the SIGTTIN signal.

Stopped (SIGTTOU)
The job was suspended by the SIGTTOU signal.

command
The command that was given to the shell.

Examples

Assign the process group leader's process ID for the current default job to the variable PGLPID:
   PGLPID=$(jobs -p %%)
Assign the PID of the command that contains the string ``foobar'':
   PGLPID=$(jobs -p %?"foobar")

Limitations

jobs is available in ksh(C) only.

You must have enabled job control (using set -m) to use jobs.

jobs must be executed within the current shell to report the jobs controlled by that shell.

See also

bg(C), kill(C), ksh(C), sigaction(S-osr5), signal(S-osr5), wait(C)

Standards conformance

jobs is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005