283 lines
9.4 KiB
HTML
283 lines
9.4 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>bg</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="bg"></a> <a name="tag_04_10"></a><!-- bg -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_04_10_01"></a>NAME</h4>
|
|
|
|
<blockquote>bg - run jobs in the background</blockquote>
|
|
|
|
<h4><a name="tag_04_10_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<div class="box"><code><tt><sup>[<a href="javascript:open_code('UP')">UP</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[Option Start]" border="0"> bg</tt> <b>[</b><i>job_id</i> <tt>...</tt><b>]</b><tt><img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"></tt></code></div>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>If job control is enabled (see the description of <a href="../utilities/set.html"><i>set</i></a> <b>-m</b>), the
|
|
<i>bg</i> utility shall resume suspended jobs from the current environment (see <a href="xcu_chap02.html#tag_02_12"><i>Shell
|
|
Execution Environment</i></a> ) by running them as background jobs. If the job specified by <i>job_id</i> is already a running
|
|
background job, the <i>bg</i> utility shall have no effect and shall exit successfully.</p>
|
|
|
|
<p>Using <i>bg</i> to place a job into the background shall cause its process ID to become "known in the current shell execution
|
|
environment", as if it had been started as an asynchronous list; see <a href="xcu_chap02.html#tag_02_09_03_02"><i>Asynchronous
|
|
Lists</i></a> .</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_04"></a>OPTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_05"></a>OPERANDS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following operand shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>job_id</i></dt>
|
|
|
|
<dd>Specify the job to be resumed as a background job. If no <i>job_id</i> operand is given, the most recently suspended job shall
|
|
be used. The format of <i>job_id</i> is described in the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/xbd_chap03.html#tag_03_203">Section 3.203, Job Control Job ID</a>.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_06"></a>STDIN</h4>
|
|
|
|
<blockquote>
|
|
<p>Not used.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_07"></a>INPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_08"></a>ENVIRONMENT VARIABLES</h4>
|
|
|
|
<blockquote>
|
|
<p>The following environment variables shall affect the execution of <i>bg</i>:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>LANG</i></dt>
|
|
|
|
<dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
|
|
the precedence of internationalization variables used to determine the values of locale categories.)</dd>
|
|
|
|
<dt><i>LC_ALL</i></dt>
|
|
|
|
<dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
|
|
|
|
<dt><i>LC_CTYPE</i></dt>
|
|
|
|
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
|
|
opposed to multi-byte characters in arguments).</dd>
|
|
|
|
<dt><i>LC_MESSAGES</i></dt>
|
|
|
|
<dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard
|
|
error.</dd>
|
|
|
|
<dt><i>NLSPATH</i></dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"></dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_09"></a>ASYNCHRONOUS EVENTS</h4>
|
|
|
|
<blockquote>
|
|
<p>Default.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_10"></a>STDOUT</h4>
|
|
|
|
<blockquote>
|
|
<p>The output of <i>bg</i> shall consist of a line in the format:</p>
|
|
|
|
<pre>
|
|
<tt>"[%d] %s\n", <</tt><i>job-number</i><tt>>, <</tt><i>command</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>where the fields are as follows:</p>
|
|
|
|
<dl compact>
|
|
<dt><<i>job-number</i>></dt>
|
|
|
|
<dd>A number that can be used to identify the job to the <a href="../utilities/wait.html"><i>wait</i></a>, <a href=
|
|
"../utilities/fg.html"><i>fg</i></a>, and <a href="../utilities/kill.html"><i>kill</i></a> utilities. Using these utilities, the
|
|
job can be identified by prefixing the job number with <tt>'%'</tt> .</dd>
|
|
|
|
<dt><<i>command</i>></dt>
|
|
|
|
<dd>The associated command that was given to the shell.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_11"></a>STDERR</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard error shall be used only for diagnostic messages.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_12"></a>OUTPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_13"></a>EXTENDED DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_14"></a>EXIT STATUS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following exit values shall be returned:</p>
|
|
|
|
<dl compact>
|
|
<dt> 0</dt>
|
|
|
|
<dd>Successful completion.</dd>
|
|
|
|
<dt>>0</dt>
|
|
|
|
<dd>An error occurred.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_15"></a>CONSEQUENCES OF ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>If job control is disabled, the <i>bg</i> utility shall exit with an error and no job shall be placed in the background.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_04_10_16"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>A job is generally suspended by typing the SUSP character (<control>-Z on most systems); see the Base Definitions volume
|
|
of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap11.html#tag_11">Chapter 11, General Terminal Interface</a>. At that
|
|
point, <i>bg</i> can put the job into the background. This is most effective when the job is expecting no terminal input and its
|
|
output has been redirected to non-terminal files. A background job can be forced to stop when it has terminal output by issuing the
|
|
command:</p>
|
|
|
|
<pre>
|
|
<tt>stty tostop
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>A background job can be stopped with the command:</p>
|
|
|
|
<pre>
|
|
<tt>kill -s stop</tt> <i>job ID</i>
|
|
</pre>
|
|
|
|
<p>The <i>bg</i> utility does not work as expected when it is operating in its own utility execution environment because that
|
|
environment has no suspended jobs. In the following examples:</p>
|
|
|
|
<pre>
|
|
<tt>... | xargs bg
|
|
(bg)
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>each <i>bg</i> operates in a different environment and does not share its parent shell's understanding of jobs. For this reason,
|
|
<i>bg</i> is generally implemented as a shell regular built-in.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_17"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_18"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>The extensions to the shell specified in this volume of IEEE Std 1003.1-2001 have mostly been based on features
|
|
provided by the KornShell. The job control features provided by <i>bg</i>, <a href="../utilities/fg.html"><i>fg</i></a>, and <a
|
|
href="../utilities/jobs.html"><i>jobs</i></a> are also based on the KornShell. The standard developers examined the characteristics
|
|
of the C shell versions of these utilities and found that differences exist. Despite widespread use of the C shell, the KornShell
|
|
versions were selected for this volume of IEEE Std 1003.1-2001 to maintain a degree of uniformity with the rest of the
|
|
KornShell features selected (such as the very popular command line editing features).</p>
|
|
|
|
<p>The <i>bg</i> utility is expected to wrap its output if the output exceeds the number of display columns.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_19"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_20"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="xcu_chap02.html#tag_02_09_03_02"><i>Asynchronous Lists</i></a> , <a href="fg.html"><i>fg</i></a> , <a href=
|
|
"kill.html"><i>kill</i>()</a> , <a href="jobs.html"><i>jobs</i></a> , <a href="wait.html"><i>wait</i>()</a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_21"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 4.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_10_22"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>This utility is marked as part of the User Portability Utilities option.</p>
|
|
|
|
<p>The JC margin marker on the SYNOPSIS is removed since support for Job Control is mandatory in this issue. This is a FIPS
|
|
requirement.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|