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
11
13 bg — run jobs in the background
14
16 bg [job_id...]
17
19 If job control is enabled (see the description of set −m), the bg util‐
20 ity shall resume suspended jobs from the current environment (see Sec‐
21 tion 2.12, Shell Execution Environment) by running them as background
22 jobs. If the job specified by job_id is already a running background
23 job, the bg utility shall have no effect and shall exit successfully.
24
25 Using bg to place a job into the background shall cause its process ID
26 to become ``known in the current shell execution environment'', as if
27 it had been started as an asynchronous list; see Section 2.9.3.1, Exam‐
28 ples.
29
31 None.
32
34 The following operand shall be supported:
35
36 job_id Specify the job to be resumed as a background job. If no
37 job_id operand is given, the most recently suspended job
38 shall be used. The format of job_id is described in the Base
39 Definitions volume of POSIX.1‐2008, Section 3.204, Job Con‐
40 trol Job ID.
41
43 Not used.
44
46 None.
47
49 The following environment variables shall affect the execution of bg:
50
51 LANG Provide a default value for the internationalization vari‐
52 ables that are unset or null. (See the Base Definitions vol‐
53 ume of POSIX.1‐2008, Section 8.2, Internationalization Vari‐
54 ables for the precedence of internationalization variables
55 used to determine the values of locale categories.)
56
57 LC_ALL If set to a non-empty string value, override the values of
58 all the other internationalization variables.
59
60 LC_CTYPE Determine the locale for the interpretation of sequences of
61 bytes of text data as characters (for example, single-byte as
62 opposed to multi-byte characters in arguments).
63
64 LC_MESSAGES
65 Determine the locale that should be used to affect the format
66 and contents of diagnostic messages written to standard
67 error.
68
69 NLSPATH Determine the location of message catalogs for the processing
70 of LC_MESSAGES.
71
73 Default.
74
76 The output of bg shall consist of a line in the format:
77
78 "[%d] %s\n", <job-number>, <command>
79
80 where the fields are as follows:
81
82 <job-number>
83 A number that can be used to identify the job to the wait,
84 fg, and kill utilities. Using these utilities, the job can be
85 identified by prefixing the job number with '%'.
86
87 <command> The associated command that was given to the shell.
88
90 The standard error shall be used only for diagnostic messages.
91
93 None.
94
96 None.
97
99 The following exit values shall be returned:
100
101 0 Successful completion.
102
103 >0 An error occurred.
104
106 If job control is disabled, the bg utility shall exit with an error and
107 no job shall be placed in the background.
108
109 The following sections are informative.
110
112 A job is generally suspended by typing the SUSP character (<control>‐Z
113 on most systems); see the Base Definitions volume of POSIX.1‐2008,
114 Chapter 11, General Terminal Interface. At that point, bg can put the
115 job into the background. This is most effective when the job is expect‐
116 ing no terminal input and its output has been redirected to non-termi‐
117 nal files. A background job can be forced to stop when it has terminal
118 output by issuing the command:
119
120 stty tostop
121
122 A background job can be stopped with the command:
123
124 kill −s stop job ID
125
126 The bg utility does not work as expected when it is operating in its
127 own utility execution environment because that environment has no sus‐
128 pended jobs. In the following examples:
129
130 ... | xargs bg
131 (bg)
132
133 each bg operates in a different environment and does not share its par‐
134 ent shell's understanding of jobs. For this reason, bg is generally
135 implemented as a shell regular built-in.
136
138 None.
139
141 The extensions to the shell specified in this volume of POSIX.1‐2008
142 have mostly been based on features provided by the KornShell. The job
143 control features provided by bg, fg, and jobs are also based on the
144 KornShell. The standard developers examined the characteristics of the
145 C shell versions of these utilities and found that differences exist.
146 Despite widespread use of the C shell, the KornShell versions were
147 selected for this volume of POSIX.1‐2008 to maintain a degree of uni‐
148 formity with the rest of the KornShell features selected (such as the
149 very popular command line editing features).
150
151 The bg utility is expected to wrap its output if the output exceeds the
152 number of display columns.
153
155 None.
156
158 Section 2.9.3.1, Examples, fg, kill, jobs, wait
159
160 The Base Definitions volume of POSIX.1‐2008, Section 3.204, Job Control
161 Job ID, Chapter 8, Environment Variables, Chapter 11, General Terminal
162 Interface
163
165 Portions of this text are reprinted and reproduced in electronic form
166 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
167 -- Portable Operating System Interface (POSIX), The Open Group Base
168 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
169 cal and Electronics Engineers, Inc and The Open Group. (This is
170 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
171 event of any discrepancy between this version and the original IEEE and
172 The Open Group Standard, the original IEEE and The Open Group Standard
173 is the referee document. The original Standard can be obtained online
174 at http://www.unix.org/online.html .
175
176 Any typographical or formatting errors that appear in this page are
177 most likely to have been introduced during the conversion of the source
178 files to man page format. To report such errors, see https://www.ker‐
179 nel.org/doc/man-pages/reporting_bugs.html .
180
181
182
183IEEE/The Open Group 2013 BG(1P)