1BG(1P) POSIX Programmer's Manual BG(1P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 bg - run jobs in the background
13
15 bg [job_id ...]
16
18 If job control is enabled (see the description of set -m), the bg util‐
19 ity shall resume suspended jobs from the current environment (see Shell
20 Execution Environment ) by running them as background jobs. If the job
21 specified by job_id is already a running background job, the bg utility
22 shall have no effect and shall exit successfully.
23
24 Using bg to place a job into the background shall cause its process ID
25 to become "known in the current shell execution environment", as if it
26 had been started as an asynchronous list; see Asynchronous Lists .
27
29 None.
30
32 The following operand shall be supported:
33
34 job_id Specify the job to be resumed as a background job. If no job_id
35 operand is given, the most recently suspended job shall be used.
36 The format of job_id is described in the Base Definitions volume
37 of IEEE Std 1003.1-2001, Section 3.203, Job Control Job ID.
38
39
41 Not used.
42
44 None.
45
47 The following environment variables shall affect the execution of bg:
48
49 LANG Provide a default value for the internationalization variables
50 that are unset or null. (See the Base Definitions volume of
51 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
52 ables for the precedence of internationalization variables used
53 to determine the values of locale categories.)
54
55 LC_ALL If set to a non-empty string value, override the values of all
56 the other internationalization variables.
57
58 LC_CTYPE
59 Determine the locale for the interpretation of sequences of
60 bytes of text data as characters (for example, single-byte as
61 opposed to multi-byte characters in arguments).
62
63 LC_MESSAGES
64 Determine the locale that should be used to affect the format
65 and contents of diagnostic messages written to standard error.
66
67 NLSPATH
68 Determine the location of message catalogs for the processing of
69 LC_MESSAGES .
70
71
73 Default.
74
76 The output of bg shall consist of a line in the format:
77
78
79 "[%d] %s\n", <job-number>, <command>
80
81 where the fields are as follows:
82
83 <job-number>
84 A number that can be used to identify the job to the wait, fg,
85 and kill utilities. Using these utilities, the job can be iden‐
86 tified by prefixing the job number with '%' .
87
88 <command>
89 The associated command that was given to the shell.
90
91
93 The standard error shall be used only for diagnostic messages.
94
96 None.
97
99 None.
100
102 The following exit values shall be returned:
103
104 0 Successful completion.
105
106 >0 An error occurred.
107
108
110 If job control is disabled, the bg utility shall exit with an error and
111 no job shall be placed in the background.
112
113 The following sections are informative.
114
116 A job is generally suspended by typing the SUSP character (<control>-Z
117 on most systems); see the Base Definitions volume of
118 IEEE Std 1003.1-2001, Chapter 11, General Terminal Interface. At that
119 point, bg can put the job into the background. This is most effective
120 when the job is expecting no terminal input and its output has been
121 redirected to non-terminal files. A background job can be forced to
122 stop when it has terminal output by issuing the command:
123
124
125 stty tostop
126
127 A background job can be stopped with the command:
128
129
130 kill -s stop job ID
131
132 The bg utility does not work as expected when it is operating in its
133 own utility execution environment because that environment has no sus‐
134 pended jobs. In the following examples:
135
136
137 ... | xargs bg
138 (bg)
139
140 each bg operates in a different environment and does not share its par‐
141 ent shell's understanding of jobs. For this reason, bg is generally
142 implemented as a shell regular built-in.
143
145 None.
146
148 The extensions to the shell specified in this volume of
149 IEEE Std 1003.1-2001 have mostly been based on features provided by the
150 KornShell. The job control features provided by bg, fg, and jobs are
151 also based on the KornShell. The standard developers examined the char‐
152 acteristics of the C shell versions of these utilities and found that
153 differences exist. Despite widespread use of the C shell, the KornShell
154 versions were selected for this volume of IEEE Std 1003.1-2001 to main‐
155 tain a degree of uniformity with the rest of the KornShell features
156 selected (such as the very popular command line editing features).
157
158 The bg utility is expected to wrap its output if the output exceeds the
159 number of display columns.
160
162 None.
163
165 Asynchronous Lists, fg, kill(), jobs, wait()
166
168 Portions of this text are reprinted and reproduced in electronic form
169 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
170 -- Portable Operating System Interface (POSIX), The Open Group Base
171 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
172 Electrical and Electronics Engineers, Inc and The Open Group. In the
173 event of any discrepancy between this version and the original IEEE and
174 The Open Group Standard, the original IEEE and The Open Group Standard
175 is the referee document. The original Standard can be obtained online
176 at http://www.opengroup.org/unix/online.html .
177
178
179
180IEEE/The Open Group 2003 BG(1P)