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