Bash/Job-Control-Builtins
Next: Job Control Variables, Previous: Job Control Basics, Up: Job Control [Contents][Index]
7.2 Job Control Builtins
bg
bg [jobspec …]
Resume each suspended job
jobspec
in the background, as if it had been started with ‘&
’. Ifjobspec
is not supplied, the current job is used. The return status is zero unless it is run when job control is not enabled, or, when run with job control enabled, anyjobspec
was not found or specifies a job that was started without job control.fg
fg [jobspec]
Resume the job
jobspec
in the foreground and make it the current job. Ifjobspec
is not supplied, the current job is used. The return status is that of the command placed into the foreground, or non-zero if run when job control is disabled or, when run with job control enabled,jobspec
does not specify a valid job orjobspec
specifies a job that was started without job control.jobs
jobs [-lnprs] [jobspec] jobs -x command [arguments]
The first form lists the active jobs. The options have the following meanings:
-l
List process IDs in addition to the normal information.
-n
Display information only about jobs that have changed status since the user was last notified of their status.
-p
List only the process ID of the job’s process group leader.
-r
Display only running jobs.
-s
Display only stopped jobs.
If
jobspec
is given, output is restricted to information about that job. Ifjobspec
is not supplied, the status of all jobs is listed.If the
-x
option is supplied,jobs
replaces anyjobspec
found incommand
orarguments
with the corresponding process group ID, and executescommand
, passing itargument
s, returning its exit status.kill
kill [-s sigspec] [-n signum] [-sigspec] jobspec or pid kill -l|-L [exit_status]
Send a signal specified by
sigspec
orsignum
to the process named by job specificationjobspec
or process IDpid
.sigspec
is either a case-insensitive signal name such asSIGINT
(with or without theSIG
prefix) or a signal number;signum
is a signal number. Ifsigspec
andsignum
are not present,SIGTERM
is used. The-l
option lists the signal names. If any arguments are supplied when-l
is given, the names of the signals corresponding to the arguments are listed, and the return status is zero.exit_status
is a number specifying a signal number or the exit status of a process terminated by a signal. The-L
option is equivalent to-l
. The return status is zero if at least one signal was successfully sent, or non-zero if an error occurs or an invalid option is encountered.wait
wait [-fn] [jobspec or pid …]
Wait until the child process specified by each process ID
pid
or job specificationjobspec
exits and return the exit status of the last command waited for. If a job spec is given, all processes in the job are waited for. If no arguments are given, all currently active child processes are waited for, and the return status is zero. If the-n
option is supplied,wait
waits for a single job to terminate and returns its exit status. Supplying the-f
option, when job control is enabled, forceswait
to wait for eachpid
orjobspec
to terminate before returning its status, intead of returning when it changes status. If neitherjobspec
norpid
specifies an active child process of the shell, the return status is 127.disown
disown [-ar] [-h] [jobspec … | pid … ]
Without options, remove each
jobspec
from the table of active jobs. If the-h
option is given, the job is not removed from the table, but is marked so thatSIGHUP
is not sent to the job if the shell receives aSIGHUP
. Ifjobspec
is not present, and neither the-a
nor the-r
option is supplied, the current job is used. If nojobspec
is supplied, the-a
option means to remove or mark all jobs; the-r
option without ajobspec
argument restricts operation to running jobs.suspend
suspend [-f]
Suspend the execution of this shell until it receives a
SIGCONT
signal. A login shell cannot be suspended; the-f
option can be used to override this and force the suspension.
When job control is not active, the kill
and wait
builtins do not accept jobspec
arguments. They must be
supplied process IDs.
Next: Job Control Variables, Previous: Job Control Basics, Up: Job Control [Contents][Index]