1JOBS(P)                    POSIX Programmer's Manual                   JOBS(P)
2
3
4

NAME

6       jobs - display status of jobs in the current session
7

SYNOPSIS

9       jobs [-l| -p][job_id...]
10

DESCRIPTION

12       The  jobs utility shall display the status of jobs that were started in
13       the current shell environment; see Shell Execution Environment .
14
15       When jobs reports the termination status of  a  job,  the  shell  shall
16       remove  its  process  ID  from  the list of those "known in the current
17       shell execution environment''; see Asynchronous Lists .
18

OPTIONS

20       The jobs utility shall  conform  to  the  Base  Definitions  volume  of
21       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
22
23       The following options shall be supported:
24
25       -l     (The  letter  ell.)  Provide  more  information  about  each job
26              listed.  This information shall include the job number,  current
27              job,  process  group  ID, state, and the command that formed the
28              job.
29
30       -p     Display only the process IDs for the process  group  leaders  of
31              the selected jobs.
32
33
34       By  default,  the  jobs utility shall display the status of all stopped
35       jobs, running background jobs and all jobs whose status has changed and
36       have not been reported by the shell.
37

OPERANDS

39       The following operand shall be supported:
40
41       job_id Specifies  the  jobs for which the status is to be displayed. If
42              no job_id is given, the status information for all jobs shall be
43              displayed. The format of job_id is described in the Base Defini‐
44              tions volume of IEEE Std 1003.1-2001, Section 3.203, Job Control
45              Job ID.
46
47

STDIN

49       Not used.
50

INPUT FILES

52       None.
53

ENVIRONMENT VARIABLES

55       The following environment variables shall affect the execution of jobs:
56
57       LANG   Provide  a  default value for the internationalization variables
58              that are unset or null. (See  the  Base  Definitions  volume  of
59              IEEE Std 1003.1-2001,  Section  8.2,  Internationalization Vari‐
60              ables for the precedence of internationalization variables  used
61              to determine the values of locale categories.)
62
63       LC_ALL If  set  to a non-empty string value, override the values of all
64              the other internationalization variables.
65
66       LC_CTYPE
67              Determine the locale for  the  interpretation  of  sequences  of
68              bytes  of  text  data as characters (for example, single-byte as
69              opposed to multi-byte characters in arguments).
70
71       LC_MESSAGES
72              Determine the locale that should be used to  affect  the  format
73              and  contents  of  diagnostic messages written to standard error
74              and informative messages written to standard output.
75
76       NLSPATH
77              Determine the location of message catalogs for the processing of
78              LC_MESSAGES .
79
80

ASYNCHRONOUS EVENTS

82       Default.
83

STDOUT

85       If the -p option is specified, the output shall consist of one line for
86       each process ID:
87
88
89              "%d\n", <process ID>
90
91       Otherwise, if the -l option is not specified, the  output  shall  be  a
92       series of lines of the form:
93
94
95              "[%d] %c %s %s\n", <job-number>, <current>, <state>, <command>
96
97       where the fields shall be as follows:
98
99       <current>
100              The  character  '+'  identifies  the job that would be used as a
101              default for the fg or bg utilities; this job can also be  speci‐
102              fied  using the job_id %+ or "%%" . The character '-' identifies
103              the job that would become the default if the current default job
104              were  to  exit;  this job can also be specified using the job_id
105              %-. For other jobs, this field is a <space>. At most one job can
106              be  identified  with  '+'  and at most one job can be identified
107              with '-' . If there is any suspended job, then the  current  job
108              shall  be  a  suspended job. If there are at least two suspended
109              jobs, then the previous job also shall be a suspended job.
110
111       <job-number>
112              A number that can be used to identify the process group  to  the
113              wait, fg, bg, and kill utilities. Using these utilities, the job
114              can be identified by prefixing the job number with '%' .
115
116       <state>
117              One of the following strings (in the POSIX locale):
118
119       Running
120              Indicates that the job has not been suspended by  a  signal  and
121              has not exited.
122
123       Done
124              Indicates that the job completed and returned exit status zero.
125
126       Done(code)
127              Indicates  that  the  job  completed normally and that it exited
128              with the specified non-zero exit status, code,  expressed  as  a
129              decimal number.
130
131       Stopped
132              Indicates that the job was suspended by the SIGTSTP signal.
133
134       Stopped (SIGTSTP)
135
136              Indicates that the job was suspended by the SIGTSTP signal.
137
138       Stopped (SIGSTOP)
139
140              Indicates that the job was suspended by the SIGSTOP signal.
141
142       Stopped (SIGTTIN)
143
144              Indicates that the job was suspended by the SIGTTIN signal.
145
146       Stopped (SIGTTOU)
147
148              Indicates that the job was suspended by the SIGTTOU signal.
149
150
151       The  implementation  may  substitute  the  string Suspended in place of
152       Stopped. If the job was terminated by a signal, the format  of  <state>
153       is  unspecified, but it shall be visibly distinct from all of the other
154       <state> formats shown here and shall indicate the name  or  description
155       of the signal causing the termination.
156
157       <command>
158              The associated command that was given to the shell.
159
160
161       If  the -l option is specified, a field containing the process group ID
162       shall be inserted before the <state> field. Also, more processes  in  a
163       process  group  may be output on separate lines, using only the process
164       ID and <command> fields.
165

STDERR

167       The standard error shall be used only for diagnostic messages.
168

OUTPUT FILES

170       None.
171

EXTENDED DESCRIPTION

173       None.
174

EXIT STATUS

176       The following exit values shall be returned:
177
178        0     Successful completion.
179
180       >0     An error occurred.
181
182

CONSEQUENCES OF ERRORS

184       Default.
185
186       The following sections are informative.
187

APPLICATION USAGE

189       The -p option is the only portable way to find out the process group of
190       a  job  because different implementations have different strategies for
191       defining the process group of the job. Usage such as $( jobs  -p)  pro‐
192       vides  a  way of referring to the process group of the job in an imple‐
193       mentation-independent way.
194
195       The jobs utility does not work as expected when it is operating in  its
196       own  utility  execution  environment  because  that  environment has no
197       applicable jobs to manipulate. See the APPLICATION USAGE section for bg
198       .  For  this  reason,  jobs is generally implemented as a shell regular
199       built-in.
200

EXAMPLES

202       None.
203

RATIONALE

205       Both "%%" and "%+" are used to refer to the current  job.   Both  forms
206       are  of  equal  validity-the "%%" mirroring "$$" and "%+" mirroring the
207       output of jobs.  Both forms reflect historical practice  of  the  Korn‐
208       Shell and the C shell with job control.
209
210       The  job control features provided by bg, fg, and jobs are based on the
211       KornShell. The standard developers examined the characteristics of  the
212       C  shell  versions of these utilities and found that differences exist.
213       Despite widespread use of the C  shell,  the  KornShell  versions  were
214       selected  for  this volume of IEEE Std 1003.1-2001 to maintain a degree
215       of uniformity with the rest of the KornShell features selected (such as
216       the very popular command line editing features).
217
218       The jobs utility is not dependent on the job control option, as are the
219       seemingly related bg and fg utilities because jobs is useful for  exam‐
220       ining  background  jobs,  regardless  of  the condition of job control.
221       When the user has invoked a set +m command and  job  control  has  been
222       turned off, jobs can still be used to examine the background jobs asso‐
223       ciated with that current session.  Similarly, kill can then be used  to
224       kill background jobs with kill% <background job number>.
225
226       The output for terminated jobs is left unspecified to accommodate vari‐
227       ous historical systems. The following formats have been witnessed:
228
229        1. Killed( signal name)
230
231        2. signal name
232
233        3. signal name( coredump)
234
235        4. signal description- core dumped
236
237       Most users should be able to  understand  these  formats,  although  it
238       means that applications have trouble parsing them.
239
240       The  calculation  of job IDs was not described since this would suggest
241       an implementation, which may impose unnecessary restrictions.
242
243       In an early proposal, a -n option was included to "Display  the  status
244       of  jobs  that  have  changed, exited, or stopped since the last status
245       report". It was removed because the shell  always  writes  any  changed
246       status of jobs before each prompt.
247

FUTURE DIRECTIONS

249       None.
250

SEE ALSO

252       Shell Execution Environment , bg , fg , kill() , wait()
253
255       Portions  of  this text are reprinted and reproduced in electronic form
256       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
257       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
258       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
259       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
260       event of any discrepancy between this version and the original IEEE and
261       The  Open Group Standard, the original IEEE and The Open Group Standard
262       is the referee document. The original Standard can be  obtained  online
263       at http://www.opengroup.org/unix/online.html .
264
265
266
267IEEE/The Open Group                  2003                              JOBS(P)
Impressum