1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
|
.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group. In the event of any discrepancy
.\" between these versions and the original IEEE and The Open Group
.\" Standard, the original IEEE and The Open Group Standard is the referee
.\" document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
.\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
.\"
.TH JOBS 1 "Nov 2, 2007"
.SH NAME
jobs, fg, bg, stop, notify \- control process execution
.SH SYNOPSIS
.SS "sh"
.LP
.nf
\fBjobs\fR [\fB-p\fR | \fB-l\fR] [% \fIjob_id\fR...]
.fi
.LP
.nf
\fBjobs\fR \fB-x\fR \fIcommand\fR [\fIarguments\fR]
.fi
.LP
.nf
\fBfg\fR [% \fIjob_id\fR...]
.fi
.LP
.nf
\fBbg\fR [% \fIjob_id\fR...]
.fi
.LP
.nf
\fBstop\fR % \fIjob_id\fR...
.fi
.LP
.nf
\fBstop\fR \fIpid\fR...
.fi
.SS "csh"
.LP
.nf
\fBjobs\fR [\fB-l\fR]
.fi
.LP
.nf
\fBfg\fR [% \fIjob_id\fR]
.fi
.LP
.nf
\fBbg\fR [% \fIjob_id\fR]...
.fi
.LP
.nf
\fBnotify\fR [% \fIjob_id\fR]...
.fi
.LP
.nf
\fBstop\fR % \fIjob_id\fR...
.fi
.LP
.nf
\fBstop\fR \fIpid\fR...
.fi
.SS "ksh"
.LP
.nf
\fBjobs\fR [\fB-lnp\fR] [% \fIjob_id\fR...]
.fi
.LP
.nf
\fBfg\fR [% \fIjob_id\fR...]
.fi
.LP
.nf
\fBbg\fR [% \fIjob_id\fR...]
.fi
.LP
.nf
\fBstop\fR % \fIjob_id\fR...
.fi
.LP
.nf
\fBstop\fR \fIpid\fR...
.fi
.SS "ksh93"
.LP
.nf
\fBjobs\fR [\fB-lnp\fR] [\fIjob_id\fR...]
.fi
.LP
.nf
\fBfg\fR [\fIjob_id\fR...]
.fi
.LP
.nf
\fBbg\fR [\fIjob_id\fR...]
.fi
.SH DESCRIPTION
.SS "sh"
.sp
.LP
When Job Control is enabled, the Bourne shell built-in \fBjobs\fR reports all
jobs that are stopped or executing in the background. If \fB%\fR\fIjob_id\fR is
omitted, all jobs that are stopped or running in the background is reported.
The following options modify or enhance the output of \fBjobs\fR:
.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.RS 6n
Reports the process group \fBID\fR and working directory of the jobs.
.RE
.sp
.ne 2
.na
\fB\fB-p\fR\fR
.ad
.RS 6n
Reports only the process group \fBID\fR of the jobs.
.RE
.sp
.ne 2
.na
\fB\fB-x\fR\fR
.ad
.RS 6n
Replaces any \fIjob_id\fR found in \fIcommand\fR or \fIarguments\fR with the
corresponding process group \fBID\fR, and then executes \fIcommand\fR passing
it \fIarguments\fR.
.RE
.sp
.LP
When the shell is invoked as \fBjsh\fR, Job Control is enabled in addition to
all of the functionality described previously for \fBsh\fR. Typically Job
Control is enabled for the interactive shell only. Non-interactive shells
typically do not benefit from the added functionality of Job Control.
.sp
.LP
With Job Control enabled every command or pipeline the user enters at the
terminal is called a \fIjob_id\fR. All jobs exist in one of the following
states: foreground, background or stopped. These terms are defined as follows:
.RS +4
.TP
1.
A job in the \fBforeground\fR has read and write access to the controlling
terminal.
.RE
.RS +4
.TP
2.
A job in the \fBbackground\fR is denied read access and has conditional
write access to the controlling terminal (see \fBstty\fR(1))
.RE
.RS +4
.TP
3.
A \fBstopped\fR job is a job that has been placed in a suspended state,
usually as a result of a \fBSIGTSTP\fR signal (see \fBsignal.h\fR(3HEAD)).
.RE
.sp
.LP
Every job that the shell starts is assigned a positive integer, called a
\fIjob_id number\fR which is tracked by the shell and are used as an identifier
to indicate a specific job. Additionally, the shell keeps track of the
\fBcurrent\fR and \fBprevious\fR jobs. The \fBcurrent job\fR is the most recent
job to be started or restarted. The \fBprevious job\fR is the first non-current
job.
.sp
.LP
The acceptable syntax for a Job Identifier is of the form:
.sp
.LP
\fB%\fR\fIjob_id\fR
.sp
.LP
where \fIjob_id\fR can be specified in any of the following formats:
.sp
.ne 2
.na
\fB\fB%\fR or \fB+\fR\fR
.ad
.RS 13n
for the current job
.RE
.sp
.ne 2
.na
\fB\fB\(mi\fR\fR
.ad
.RS 13n
for the previous job
.RE
.sp
.ne 2
.na
\fB\fB?\fR\fI<string>\fR\fR
.ad
.RS 13n
specify the job for which the command line uniquely contains \fIstring\fR.
.RE
.sp
.ne 2
.na
\fB\fIn\fR\fR
.ad
.RS 13n
for job number \fIn\fR, where \fIn\fR is a job number
.RE
.sp
.ne 2
.na
\fB\fIpref\fR\fR
.ad
.RS 13n
where \fIpref\fR is a unique prefix of the command name (for example, if the
command \fBls \(mil name\fR were running in the background, it could be
referred to as \fB%ls\fR); \fIpref\fR cannot contain blanks unless it is
quoted.
.RE
.sp
.LP
When Job Control is enabled, \fBfg\fR resumes the execution of a stopped job in
the foreground, also moves an executing background job into the foreground. If
\fB%\fR\fIjob_id\fR is omitted the current job is assumed.
.sp
.LP
When Job Control is enabled, \fBbg\fR resumes the execution of a stopped job in
the background. If \fB%\fR\fIjob_id\fR is omitted the current job is assumed.
.sp
.LP
\fBstop\fR stops the execution of a background job(s) by using its
\fIjob_id\fR, or of any process by using its \fIpid\fR; see \fBps\fR(1).
.SS "csh"
.sp
.LP
The C shell built-in, \fBjobs\fR, without an argument, lists the active jobs
under job control.
.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.RS 6n
List process \fBID\fRs, in addition to the normal information.
.RE
.sp
.LP
The shell associates a numbered \fIjob_id\fR with each command sequence to keep
track of those commands that are running in the background or have been stopped
with \fBTSTP\fR signals (typically Control-Z). When a command or command
sequence (semicolon-separated list) is started in the background using the
\fB&\fR metacharacter, the shell displays a line with the job number in
brackets and a list of associated process numbers:
.sp
.LP
\fB[1] 1234\fR
.sp
.LP
To see the current list of jobs, use the \fBjobs\fR built-in command. The job
most recently stopped (or put into the background if none are stopped) is
referred to as the \fBcurrent\fR job and is indicated with a `\fB+\fR'. The
previous job is indicated with a `\fB\(mi\fR\&'; when the current job is
terminated or moved to the foreground, this job takes its place (becomes the
new current job).
.sp
.LP
To manipulate jobs, refer to the \fBbg\fR, \fBfg\fR, \fBkill\fR, \fBstop\fR,
and \fB%\fR built-in commands.
.sp
.LP
A reference to a job begins with a `\fB%\fR'. By itself, the percent sign
refers to the current job.
.sp
.ne 2
.na
\fB\fB%\fR \fB%+\fR \fB%%\fR\fR
.ad
.RS 12n
The current job.
.RE
.sp
.ne 2
.na
\fB\fB%\(mi\fR\fR
.ad
.RS 12n
The previous job.
.RE
.sp
.ne 2
.na
\fB\fB%\fR\fIj\fR\fR
.ad
.RS 12n
Refer to job \fIj\fR as in: `\fBkill\fR \fB-9\fR \fB%\fR\fIj\fR'. \fIj\fR can
be a job number, or a string that uniquely specifies the command line by which
it was started; `\fBfg %vi\fR' might bring a stopped \fBvi\fR job to the
foreground, for instance.
.RE
.sp
.ne 2
.na
\fB\fB%?\fR\fIstring\fR\fR
.ad
.RS 12n
Specify the job for which the command line uniquely contains \fIstring\fR.
.RE
.sp
.LP
A job running in the background stops when it attempts to read from the
terminal. Background jobs can normally produce output, but this can be
suppressed using the `\fBstty tostop\fR' command.
.sp
.LP
\fBfg\fR brings the current or specified \fIjob_id\fR into the foreground.
.sp
.LP
\fBbg\fR runs the current or specified jobs in the background.
.sp
.LP
\fBstop\fR stops the execution of a background job(s) by using its
\fIjob_id\fR, or of any process by using its \fIpid\fR; see \fBps\fR(1).
.sp
.LP
\fBnotify\fR notifies the user asynchronously when the status of the current
job or specified jobs changes.
.SS "ksh"
.sp
.LP
\fBjobs\fR displays the status of the jobs that were started in the current
shell environment. When \fBjobs\fR reports the termination status of a job, the
shell removes its process \fBID\fR from the list of those known in the current
shell execution environment.
.sp
.LP
\fIjob_id\fR specifies the jobs for which the status is to be displayed. If no
\fIjob_id\fR is specified, the status information for all jobs are displayed.
.sp
.LP
The following options modify or enhance the output of \fBjobs\fR:
.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.RS 6n
(The letter ell.) Provides more information about each job listed. This
information includes the job number, current job, process group \fBID\fR, state
and the command that formed the job.
.RE
.sp
.ne 2
.na
\fB\fB-n\fR\fR
.ad
.RS 6n
Displays only jobs that have stopped or exited since last notified.
.RE
.sp
.ne 2
.na
\fB\fB-p\fR\fR
.ad
.RS 6n
Displays only the process \fBID\fRs for the process group leaders of the
selected jobs.
.RE
.sp
.LP
By default, \fBjobs\fR displays the status of all the stopped jobs, running
background jobs, and all jobs whose status has changed and have not been
reported by the shell.
.sp
.LP
If the \fBmonitor\fR option of the \fBset\fR command is turned on, an
interactive shell associates a \fBjob\fR with each pipeline. It keeps a table
of current jobs, printed by the \fBjobs\fR command, and assigns them small
integer numbers. When a job is started asynchronously with \fB&\fR, the shell
prints a line which looks like:
.sp
.LP
\fB[1]\fR \fB1234\fR
.sp
.LP
indicating that the job, which was started asynchronously, was job number
\fB1\fR and had one (top-level) process, whose process id was \fB1234\fR.
.sp
.LP
If you are running a job and wish to do something else you can hit the key ^Z
(Control-Z) which sends a \fBSTOP\fR signal to the current job. The shell then
normally indicates that the job has been "\fBStopped\fR" (see \fBOUTPUT\fR
below), and print another prompt. You can then manipulate the state of this
job, putting it in the background with the \fBbg\fR command, or run some other
commands and then eventually bring the job back into the foreground with the
foreground command \fBfg\fR. A ^Z takes effect immediately and is like an
interrupt, in that pending output and unread input are discarded when it is
typed.
.sp
.LP
There are several ways to refer to jobs in the shell. A job can be referred to
by the process id of any process of the job or by one of the following:
.sp
.ne 2
.na
\fB\fB%\fR\fInumber\fR\fR
.ad
.RS 12n
The job with the specified number.
.RE
.sp
.ne 2
.na
\fB\fB%\fR\fIstring\fR\fR
.ad
.RS 12n
Any job whose command line begins with \fIstring\fR; works only in the
interactive mode when the history file is active.
.RE
.sp
.ne 2
.na
\fB\fB%?\fR\fIstring\fR\fR
.ad
.RS 12n
Any job whose command line contains \fIstring\fR; works only in the interactive
mode when the history file is active.
.RE
.sp
.ne 2
.na
\fB\fB%%\fR\fR
.ad
.RS 12n
Current job.
.RE
.sp
.ne 2
.na
\fB\fB%+\fR\fR
.ad
.RS 12n
Equivalent to \fB%%\fR.
.RE
.sp
.ne 2
.na
\fB\fB%\(mi\fR\fR
.ad
.RS 12n
Previous job.
.RE
.sp
.LP
The shell learns immediately whenever a process changes state. It normally
informs you whenever a job becomes blocked so that no further progress is
possible, but only just before it prints a prompt. This is done so that it does
not otherwise disturb your work. When the monitor mode is on, each background
job that completes triggers any trap set for \fBCHLD\fR. When you try to leave
the shell while jobs are running or stopped, you are warned that `You have
stopped (running) jobs.' You can use the \fBjobs\fR command to see what they
are. If you do this or immediately try to exit again, the shell does not warn
you a second time, and the stopped jobs are terminated.
.sp
.LP
\fBfg\fR moves a background job from the current environment into the
foreground. Using \fBfg\fR to place a job in the foreground removes its process
\fBID\fR from the list of those known in the current shell execution
environment. The \fBfg\fR command is available only on systems that support job
control. If \fIjob_id\fR is not specified, the current job is brought into the
foreground.
.sp
.LP
\fBbg\fR resumes suspended jobs from the current environment by running them as
background jobs. If the job specified by \fIjob_id\fR is already a running
background job, \fBbg\fR has no effect and exits successfully. Using \fBbg\fR
to place a job into the background causes its process \fBID\fR to become `known
in the current shell execution environment, as if it had been started as an
asynchronous list. The \fBbg\fR command is available only on systems that
support job control. If \fIjob_id\fR is not specified, the current job is
placed in the background.
.sp
.LP
\fBstop\fR stops the execution of a background job(s) by using its
\fIjob_id\fR, or of any process by using its \fIpid\fR. See \fBps\fR(1).
.SS "ksh93"
.sp
.LP
\fBjobs\fR displays information about specified jobs that were started by the
current shell environment on standard output. The information contains the job
number enclosed in \fB[...]\fR, the status, and the command line that started
the job.
.sp
.LP
If \fIjob_id\fR is omitted, \fBjobs\fR displays the status of all stopped jobs,
background jobs, and all jobs whose status has changed since last reported by
the shell.
.sp
.LP
When \fBjobs\fR reports the termination status of a job, the shell removes the
job from the list of known jobs in the current shell environment.
.sp
.LP
The following options modify or enhances the output of \fBjobs\fR:
.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.RS 6n
Displays process IDs after the job number in addition to the usual information.
.RE
.sp
.ne 2
.na
\fB\fB-n\fR\fR
.ad
.RS 6n
Displays only the jobs whose status has changed since the last prompt was
displayed.
.RE
.sp
.ne 2
.na
\fB\fB-p\fR\fR
.ad
.RS 6n
Displays the process group leader IDs for the specified jobs.
.RE
.sp
.LP
\fIjob_id\fR can be specified to \fBjobs\fR, \fBfg\fR, and \fBbg\fR as one of
the following:
.sp
.ne 2
.na
\fB\fInumber\fR\fR
.ad
.RS 12n
The process id of \fBjob\fR.
.RE
.sp
.ne 2
.na
\fB\fB-\fR\fInumber\fR\fR
.ad
.RS 12n
The process group id of \fBjob\fR.
.RE
.sp
.ne 2
.na
\fB\fB%\fR\fInumber\fR\fR
.ad
.RS 12n
The job number.
.RE
.sp
.ne 2
.na
\fB\fB%\fR\fIstring\fR\fR
.ad
.RS 12n
The job whose name begins with \fIstring\fR.
.RE
.sp
.ne 2
.na
\fB\fB%?\fR\fIstring\fR\fR
.ad
.RS 12n
The job whose name contains \fIstring\fR.
.RE
.sp
.ne 2
.na
\fB\fB%+\fR\fR
.ad
.br
.na
\fB\fB%%\fR\fR
.ad
.RS 12n
The current job.
.RE
.sp
.ne 2
.na
\fB\fB%-\fR\fR
.ad
.RS 12n
The previous job.
.RE
.sp
.LP
\fBfg\fR places the specified jobs into the foreground in sequence and sends a
\fBCONT\fR signal to start each running. If \fIjob_id\fR is omitted, the most
recently started or stopped background job is moved to the foreground.
.sp
.LP
\fBbg\fR places the specified jobs into the background and sends a \fBCONT\fR
signal to start them running. If \fIjob_id\fR is omitted, the most recently
started or stopped background job is resumed or continued in the background.
.SH OUTPUT
.sp
.LP
If the \fB-p\fR option is specified, the output consists of one line for each
process \fBID\fR:
.sp
.LP
\fB"%d\en",\fR \fI"process ID"\fR
.sp
.LP
Otherwise, if the \fB-l\fR option is not specified, the output is a series of
lines of the form:
.sp
.LP
\fB"[%d] %c %s %s\en"\fR, \fIjob-number\fR, \fIcurrent\fR, \fIstate\fR,
\fIcommand\fR
.sp
.LP
where the fields are as follows:
.sp
.ne 2
.na
\fB\fIcurrent\fR\fR
.ad
.RS 14n
The character \fB+\fR identifies the job that would be used as a default for
the \fBfg\fR or \fBbg\fR commands. This job can also be specified using the
\fIjob_id\fR \fB%+\fR or \fB%%\fR \fB\&.\fR The character \fB\(mi\fR identifies
the job that would become the default if the current default job were to exit;
this job can also be specified using the \fIjob_id\fR \fB%\(mi\fR \fB\&.\fR For
other jobs, this field is a space character. At most, one job can be identified
with \fB+\fR and at most one job can be identified with \fB\(mi\fR\&. If there
is any suspended job, then the current job is a suspended job. If there are at
least two suspended jobs, then the previous job is also a suspended job.
.RE
.sp
.ne 2
.na
\fB\fIjob-number\fR\fR
.ad
.RS 14n
A number that can be used to identify the process group to the \fBwait\fR,
\fBfg\fR, \fBbg,\fR and \fBkill\fR utilities. Using these utilities, the job
can be identified by prefixing the job number with \fB%\fR.
.RE
.sp
.ne 2
.na
\fB\fIstate\fR\fR
.ad
.RS 14n
One of the following strings in the POSIX Locale:
.sp
.ne 2
.na
\fB\fBRunning\fR\fR
.ad
.RS 20n
Indicates that the job has not been suspended by a signal and has not exited.
.RE
.sp
.ne 2
.na
\fB\fBDone\fR\fR
.ad
.RS 20n
Indicates that the job completed and returned exit status zero.
.RE
.sp
.ne 2
.na
\fB\fBDone\fR(\fIcode\fR)\fR
.ad
.RS 20n
Indicates that the job completed normally and that it exited with the specified
\fBnon-zero\fR exit status, \fIcode\fR, expressed as a decimal number.
.RE
.sp
.ne 2
.na
\fB\fBStopped\fR\fR
.ad
.RS 20n
Indicates that the job was stopped.
.RE
.sp
.ne 2
.na
\fB\fBStopped(SIGTSTP)\fR\fR
.ad
.RS 20n
Indicates that the job was suspended by the \fBSIGTSTP\fR signal.
.RE
.sp
.ne 2
.na
\fB\fBStopped(SIGSTOP)\fR\fR
.ad
.RS 20n
Indicates that the job was suspended by the \fBSIGSTOP\fR signal.
.RE
.sp
.ne 2
.na
\fB\fBStopped(SIGTTIN)\fR\fR
.ad
.RS 20n
Indicates that the job was suspended by the \fBSIGTTIN\fR signal.
.RE
.sp
.ne 2
.na
\fB\fBStopped(SIGTTOU)\fR\fR
.ad
.RS 20n
Indicates that the job was suspended by the \fBSIGTTOU\fR signal.
.RE
The implementation can substitute the string \fBSuspended\fR in place of
\fBStopped\fR. If the job was terminated by a signal, the format of \fBstate\fR
is unspecified, but it is visibly distinct from all of the other \fBstate\fR
formats shown here and indicates the name or description of the signal causing
the termination.
.RE
.sp
.ne 2
.na
\fB\fIcommand\fR\fR
.ad
.RS 14n
The associated command that was specified to the shell.
.RE
.sp
.LP
If the \fB-l\fR option is specified, a field containing the process group
\fBID\fR is inserted before the \fBstate\fR field. Also, more processes in a
process group can be output on separate lines, using only the process \fBID\fR
and \fBcommand\fR fields.
.SH ENVIRONMENT VARIABLES
.sp
.LP
See \fBenviron\fR(7) for descriptions of the following environment variables
that affect the execution of \fBjobs\fR, \fBfg\fR, and \fBbg\fR: \fBLANG\fR,
\fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
.SH EXIT STATUS
.SS "sh, csh, ksh"
.sp
.LP
The following exit values are returned for \fBjobs\fR, \fBfg\fR, and \fBbg\fR:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
Successful completion.
.RE
.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE
.SS "ksh93"
.sp
.LP
The following exit values are returned for \fBjobs\fR:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
The information for each job is written to standard output.
.RE
.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
One or more jobs does not exist.
.RE
.sp
.LP
The following exit values are returned for \fBfg\fR:
.sp
.ne 2
.na
\fB\fBexit status of last job\fR\fR
.ad
.RS 27n
One or more jobs has been brought into the foreground.
.RE
.sp
.ne 2
.na
\fB\fBnon-zero\fR\fR
.ad
.RS 27n
One or more jobs does not exist or has completed.
.RE
.sp
.LP
The following exit values are returned for \fBbg\fR:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
All background jobs are started.
.RE
.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
One more jobs does not exist or there are no background jobs.
.RE
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.SS "csh, sh, ksh"
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Committed
_
Standard See \fBstandards\fR(7).
.TE
.SS "ksh93"
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Uncommitted
.TE
.SH SEE ALSO
.sp
.LP
.BR csh (1),
.BR kill (1),
.BR ksh (1),
.BR ksh93 (1),
.BR ps (1),
.BR sh (1),
.BR shell_builtins (1),
.BR stop (1),
.BR stty (1),
.BR wait (1),
.BR signal.h (3HEAD),
.BR attributes (7),
.BR environ (7),
.BR standards (7)
|