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