Un outil pour savoir si une commande est posix - retour accueil
git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |
jobs.html (18559B)
1 <!-- Copyright 2001-2024 IEEE and The Open Group, All Rights Reserved --> 2 <!DOCTYPE HTML> 3 <html lang="en"> 4 <head> 5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.8.0"> 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 7 <link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group rhtm tool v1.2.4 --> 8 <!-- Copyright (c) 2001-2024 The Open Group, All Rights Reserved --> 9 <title>jobs</title> 10 </head> 11 <body bgcolor="white"> 12 <div class="NAVHEADER"> 13 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 14 <tr class="nav"> 15 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/ipcs.html" accesskey="P"><<< 16 Previous</a></td> 17 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 18 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/join.html" accesskey="N">Next >>></a></td> 19 </tr> 20 </table> 21 <hr align="left" width="100%"></div> 22 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> 23 <center><font size="2">The Open Group Base Specifications Issue 8<br> 24 IEEE Std 1003.1-2024<br> 25 Copyright © 2001-2024 The IEEE and The Open Group</font></center> 26 <hr size="2" noshade> 27 <a name="top" id="top"></a> <a name="jobs" id="jobs"></a> <a name="tag_20_62" id="tag_20_62"></a><!-- jobs --> 28 <h4 class="mansect"><a name="tag_20_62_01" id="tag_20_62_01"></a>NAME</h4> 29 <blockquote>jobs — display status of jobs in the current shell execution environment</blockquote> 30 <h4 class="mansect"><a name="tag_20_62_02" id="tag_20_62_02"></a>SYNOPSIS</h4> 31 <blockquote class="synopsis"> 32 <div class="box"><code><tt><sup>[<a href="javascript:open_code('UP')">UP</a>]</sup> <img src="../images/opt-start.gif" alt= 33 "[Option Start]" border="0"> jobs</tt> <b>[</b><tt>-l|-p</tt><b>] [</b><i>job_id</i><tt>...</tt><b>]</b> <tt><img src= 34 "../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div> 35 </blockquote> 36 <h4 class="mansect"><a name="tag_20_62_03" id="tag_20_62_03"></a>DESCRIPTION</h4> 37 <blockquote> 38 <p>If the current shell execution environment (see <a href="../utilities/V3_chap02.html#tag_19_13"><i>2.13 Shell Execution 39 Environment</i></a> ) is not a subshell environment, the <i>jobs</i> utility shall display the status of background jobs that were 40 created in the current shell execution environment; it may also do so if the current shell execution environment is a subshell 41 environment.</p> 42 <p>When <i>jobs</i> reports the termination status of a job, the shell shall remove the job from the background jobs list and the 43 associated process ID from the list of those "known in the current shell execution environment"; see <a href= 44 "../utilities/V3_chap02.html#tag_19_09_03_02"><i>2.9.3.1 Asynchronous AND-OR Lists</i></a> . If a write error occurs when 45 <i>jobs</i> writes to standard output, some process IDs might have been removed from the list but not successfully reported.</p> 46 </blockquote> 47 <h4 class="mansect"><a name="tag_20_62_04" id="tag_20_62_04"></a>OPTIONS</h4> 48 <blockquote> 49 <p>The <i>jobs</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax 50 Guidelines</i></a> .</p> 51 <p>The following options shall be supported:</p> 52 <dl compact> 53 <dd></dd> 54 <dt><b>-l</b></dt> 55 <dd>(The letter ell.) Provide more information about each job listed. See STDOUT for details.</dd> 56 <dt><b>-p</b></dt> 57 <dd>Display only the process IDs for the process group leaders of job-control background jobs and the process IDs associated with 58 non-job-control background jobs (if supported).</dd> 59 </dl> 60 <p>By default, the <i>jobs</i> utility shall display the status of all background jobs, both running and suspended, and all jobs 61 whose status has changed and have not been reported by the shell.</p> 62 </blockquote> 63 <h4 class="mansect"><a name="tag_20_62_05" id="tag_20_62_05"></a>OPERANDS</h4> 64 <blockquote> 65 <p>The following operand shall be supported:</p> 66 <dl compact> 67 <dd></dd> 68 <dt><i>job_id</i></dt> 69 <dd>Specifies the jobs for which the status is to be displayed. If no <i>job_id</i> is given, the status information for all jobs 70 shall be displayed. The format of <i>job_id</i> is described in XBD <a href="../basedefs/V1_chap03.html#tag_03_182"><i>3.182 Job 71 ID</i></a> .</dd> 72 </dl> 73 </blockquote> 74 <h4 class="mansect"><a name="tag_20_62_06" id="tag_20_62_06"></a>STDIN</h4> 75 <blockquote> 76 <p>Not used.</p> 77 </blockquote> 78 <h4 class="mansect"><a name="tag_20_62_07" id="tag_20_62_07"></a>INPUT FILES</h4> 79 <blockquote> 80 <p>None.</p> 81 </blockquote> 82 <h4 class="mansect"><a name="tag_20_62_08" id="tag_20_62_08"></a>ENVIRONMENT VARIABLES</h4> 83 <blockquote> 84 <p>The following environment variables shall affect the execution of <i>jobs</i>:</p> 85 <dl compact> 86 <dd></dd> 87 <dt><i>LANG</i></dt> 88 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href= 89 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization 90 variables used to determine the values of locale categories.)</dd> 91 <dt><i>LC_ALL</i></dt> 92 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd> 93 <dt><i>LC_CTYPE</i></dt> 94 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as 95 opposed to multi-byte characters in arguments).</dd> 96 <dt><i>LC_MESSAGES</i></dt> 97 <dd><br> 98 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and 99 informative messages written to standard output.</dd> 100 <dt><i>NLSPATH</i></dt> 101 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> 102 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border= 103 "0"></dd> 104 </dl> 105 </blockquote> 106 <h4 class="mansect"><a name="tag_20_62_09" id="tag_20_62_09"></a>ASYNCHRONOUS EVENTS</h4> 107 <blockquote> 108 <p>Default.</p> 109 </blockquote> 110 <h4 class="mansect"><a name="tag_20_62_10" id="tag_20_62_10"></a>STDOUT</h4> 111 <blockquote> 112 <p>If the <b>-p</b> option is specified, the output shall consist of one line for each process ID:</p> 113 <pre> 114 <tt>"%d\n", <</tt><i>process ID</i><tt>> 115 </tt></pre> 116 <p>Otherwise, if the <b>-l</b> option is not specified, the output shall be a series of lines of the form:</p> 117 <pre> 118 <tt>"[%d] %c %s %s\n", <</tt><i>job-number</i><tt>>, <</tt><i>current</i><tt>>, <</tt><i>state</i><tt>>, <</tt><i>command</i><tt>> 119 </tt></pre> 120 <p>where the fields shall be as follows:</p> 121 <dl compact> 122 <dd></dd> 123 <dt><<i>current</i>></dt> 124 <dd>The character <tt>'+'</tt> identifies the job that would be used as a default for the <a href= 125 "../utilities/fg.html"><i>fg</i></a> or <a href="../utilities/bg.html"><i>bg</i></a> utilities; this job can also be specified 126 using the <i>job_id</i> %+ or <tt>"%%"</tt>. The character <tt>'-'</tt> identifies the job that would become the default if the 127 current default job were to exit; this job can also be specified using the <i>job_id</i> %-. For other jobs, this field is a 128 <space>. At most one job can be identified with <tt>'+'</tt> and at most one job can be identified with <tt>'-'</tt>. If 129 there is any suspended job, then the current job shall be a suspended job. If there are at least two suspended jobs, then the 130 previous job also shall be a suspended job.</dd> 131 <dt><<i>job-number</i>></dt> 132 <dd>A number that can be used to identify the job to the <a href="../utilities/wait.html"><i>wait</i></a>, <a href= 133 "../utilities/fg.html"><i>fg</i></a>, <a href="../utilities/bg.html"><i>bg</i></a>, and <a href= 134 "../utilities/kill.html"><i>kill</i></a> utilities. Using these utilities, the job can be identified by prefixing the job number 135 with <tt>'%'</tt>.</dd> 136 <dt><<i>state</i>></dt> 137 <dd>One of the following strings (in the POSIX locale): 138 <dl compact> 139 <dd></dd> 140 <dt><b>Running</b></dt> 141 <dd>Indicates that the job has not been suspended by a signal and has not exited.</dd> 142 <dt><b>Done</b></dt> 143 <dd>Indicates that the job completed and returned exit status zero.</dd> 144 <dt><b>Done</b>(<i>code</i>)</dt> 145 <dd>Indicates that the job completed normally and that it exited with the specified non-zero exit status, <i>code</i>, expressed as 146 a decimal number.</dd> 147 <dt><b>Stopped</b></dt> 148 <dd>Indicates that the job was suspended by the SIGTSTP signal.</dd> 149 <dt><b>Stopped</b> (<b>SIGTSTP</b>)</dt> 150 <dd><br> 151 Indicates that the job was suspended by the SIGTSTP signal.</dd> 152 <dt><b>Stopped</b> (<b>SIGSTOP</b>)</dt> 153 <dd><br> 154 Indicates that the job was suspended by the SIGSTOP signal.</dd> 155 <dt><b>Stopped</b> (<b>SIGTTIN</b>)</dt> 156 <dd><br> 157 Indicates that the job was suspended by the SIGTTIN signal.</dd> 158 <dt><b>Stopped</b> (<b>SIGTTOU</b>)</dt> 159 <dd><br> 160 Indicates that the job was suspended by the SIGTTOU signal.</dd> 161 </dl> 162 <p>The implementation may substitute the string <b>Suspended</b> in place of <b>Stopped</b>. If the job was terminated by a signal, 163 the format of <<i>state</i>> is unspecified, but it shall be visibly distinct from all of the other <<i>state</i>> 164 formats shown here and shall indicate the name or description of the signal causing the termination.</p> 165 </dd> 166 <dt><<i>command</i>></dt> 167 <dd>The associated command that was given to the shell.</dd> 168 </dl> 169 <p>If the <b>-l</b> option is specified:</p> 170 <ul> 171 <li> 172 <p>For job-control background jobs, a field containing the process group ID shall be inserted before the <<i>state</i>> 173 field. Also, more processes in a process group may be output on separate lines, using only the process ID and 174 <<i>command</i>> fields.</p> 175 </li> 176 <li> 177 <p>For non-job-control background jobs (if supported), a field containing the process ID associated with the job shall be inserted 178 before the <<i>state</i>> field. Also, more processes created to execute the job may be output on separate lines, using only 179 the process ID and <<i>command</i>> fields.</p> 180 </li> 181 </ul> 182 </blockquote> 183 <h4 class="mansect"><a name="tag_20_62_11" id="tag_20_62_11"></a>STDERR</h4> 184 <blockquote> 185 <p>The standard error shall be used only for diagnostic messages.</p> 186 </blockquote> 187 <h4 class="mansect"><a name="tag_20_62_12" id="tag_20_62_12"></a>OUTPUT FILES</h4> 188 <blockquote> 189 <p>None.</p> 190 </blockquote> 191 <h4 class="mansect"><a name="tag_20_62_13" id="tag_20_62_13"></a>EXTENDED DESCRIPTION</h4> 192 <blockquote> 193 <p>None.</p> 194 </blockquote> 195 <h4 class="mansect"><a name="tag_20_62_14" id="tag_20_62_14"></a>EXIT STATUS</h4> 196 <blockquote> 197 <p>The following exit values shall be returned:</p> 198 <dl compact> 199 <dd></dd> 200 <dt> 0</dt> 201 <dd>The output specified in STDOUT was successfully written to standard output.</dd> 202 <dt>>0</dt> 203 <dd>An error occurred.</dd> 204 </dl> 205 </blockquote> 206 <h4 class="mansect"><a name="tag_20_62_15" id="tag_20_62_15"></a>CONSEQUENCES OF ERRORS</h4> 207 <blockquote> 208 <p>Default.</p> 209 </blockquote> 210 <hr> 211 <div class="box"><em>The following sections are informative.</em></div> 212 <h4 class="mansect"><a name="tag_20_62_16" id="tag_20_62_16"></a>APPLICATION USAGE</h4> 213 <blockquote> 214 <p>This utility is required to be intrinsic. See <a href="../utilities/V3_chap01.html#tag_18_07"><i>1.7 Intrinsic Utilities</i></a> 215 for details.</p> 216 <p>The <b>-p</b> option is the only portable way to find out the process group of a job-control background job because different 217 implementations have different strategies for defining the process group of the job. Usage such as $(<i>jobs</i> <b>-p</b>) 218 provides a way of referring to the process group of the job in an implementation-independent way.</p> 219 <p>The <i>jobs</i> utility does not work as expected when it is operating in its own utility execution environment because that 220 environment has no applicable jobs to manipulate. See the APPLICATION USAGE section for <a href= 221 "../utilities/bg.html#"><i>bg</i></a> . For this reason, <i>jobs</i> is generally implemented as a shell regular built-in.</p> 222 </blockquote> 223 <h4 class="mansect"><a name="tag_20_62_17" id="tag_20_62_17"></a>EXAMPLES</h4> 224 <blockquote> 225 <p>None.</p> 226 </blockquote> 227 <h4 class="mansect"><a name="tag_20_62_18" id="tag_20_62_18"></a>RATIONALE</h4> 228 <blockquote> 229 <p>Both <tt>"%%"</tt> and <tt>"%+"</tt> are used to refer to the current job. Both forms are of equal validity—the <tt>"%%"</tt> 230 mirroring <tt>"$$"</tt> and <tt>"%+"</tt> mirroring the output of <i>jobs</i>. Both forms reflect historical practice of the 231 KornShell and the C shell with job control.</p> 232 <p>The job control features provided by <a href="../utilities/bg.html"><i>bg</i></a>, <a href="../utilities/fg.html"><i>fg</i></a>, 233 and <i>jobs</i> are based on the KornShell. The standard developers examined the characteristics of the C shell versions of these 234 utilities and found that differences exist. Despite widespread use of the C shell, the KornShell versions were selected for this 235 volume of POSIX.1-2024 to maintain a degree of uniformity with the rest of the KornShell features selected (such as the very 236 popular command line editing features).</p> 237 <p>The <i>jobs</i> utility is not dependent on job control being enabled, as are the seemingly related <a href= 238 "../utilities/bg.html"><i>bg</i></a> and <a href="../utilities/fg.html"><i>fg</i></a> utilities because <i>jobs</i> is useful for 239 examining background jobs, regardless of the current state of job control. When job control has been disabled using <a href= 240 "../utilities/V3_chap02.html#set"><i>set</i></a> <b>+m</b>, the <i>jobs</i> utility can still be used to examine the job-control 241 background jobs and (if supported) non-job-control background jobs that were created in the current shell execution environment. 242 See also the RATIONALE for <a href="../utilities/kill.html"><i>kill</i></a> and <a href= 243 "../utilities/wait.html"><i>wait</i></a>.</p> 244 <p>The output for terminated jobs is left unspecified to accommodate various historical systems. The following formats have been 245 witnessed:</p> 246 <ol> 247 <li> 248 <p><b>Killed</b>(<i>signal name</i>)</p> 249 </li> 250 <li> 251 <p><i>signal name</i></p> 252 </li> 253 <li> 254 <p><i>signal name</i>(<b>coredump</b>)</p> 255 </li> 256 <li> 257 <p><i>signal description</i>- <b>core dumped</b></p> 258 </li> 259 </ol> 260 <p>Most users should be able to understand these formats, although it means that applications have trouble parsing them.</p> 261 <p>The calculation of job IDs was not described since this would suggest an implementation, which may impose unnecessary 262 restrictions.</p> 263 <p>In an early proposal, a <b>-n</b> option was included to "Display the status of jobs that have changed, exited, or stopped 264 since the last status report". It was removed because the shell always writes any changed status of jobs before each prompt.</p> 265 <p>If <i>jobs</i> uses buffered writes to standard output, a write error could be detected when attempting to flush a buffer 266 containing multiple reports of terminated jobs, resulting in some unreported jobs having their process IDs removed from the list of 267 those known in the current shell execution environment (because they were removed when the report was added to the buffer).</p> 268 </blockquote> 269 <h4 class="mansect"><a name="tag_20_62_19" id="tag_20_62_19"></a>FUTURE DIRECTIONS</h4> 270 <blockquote> 271 <p>None.</p> 272 </blockquote> 273 <h4 class="mansect"><a name="tag_20_62_20" id="tag_20_62_20"></a>SEE ALSO</h4> 274 <blockquote> 275 <p><a href="../utilities/V3_chap02.html#tag_19_13"><i>2.13 Shell Execution Environment</i></a> , <a href= 276 "../utilities/bg.html#"><i>bg</i></a> , <a href="../utilities/fg.html#"><i>fg</i></a> , <a href= 277 "../utilities/kill.html#tag_20_64"><i>kill</i></a> , <a href="../utilities/wait.html#tag_20_147"><i>wait</i></a></p> 278 <p>XBD <a href="../basedefs/V1_chap03.html#tag_03_182"><i>3.182 Job ID</i></a> , <a href="../basedefs/V1_chap08.html#tag_08"><i>8. 279 Environment Variables</i></a> , <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p> 280 </blockquote> 281 <h4 class="mansect"><a name="tag_20_62_21" id="tag_20_62_21"></a>CHANGE HISTORY</h4> 282 <blockquote> 283 <p>First released in Issue 4.</p> 284 </blockquote> 285 <h4 class="mansect"><a name="tag_20_62_22" id="tag_20_62_22"></a>Issue 6</h4> 286 <blockquote> 287 <p>This utility is marked as part of the User Portability Utilities option.</p> 288 <p>The JC shading is removed as job control is mandatory in this version.</p> 289 </blockquote> 290 <h4 class="mansect"><a name="tag_20_62_23" id="tag_20_62_23"></a>Issue 7</h4> 291 <blockquote> 292 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p> 293 </blockquote> 294 <h4 class="mansect"><a name="tag_20_62_24" id="tag_20_62_24"></a>Issue 8</h4> 295 <blockquote> 296 <p>Austin Group Defect 854 is applied, adding a note to the APPLICATION USAGE section that this utility is required to be 297 intrinsic.</p> 298 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p> 299 <p>Austin Group Defect 1254 is applied, updating various requirements for the <i>jobs</i> utility to account for the addition of 300 <a href="../utilities/V3_chap02.html#tag_19_11"><i>2.11 Job Control</i></a> .</p> 301 <p>Austin Group Defect 1492 is applied, clarifying the requirements when a write error to standard output occurs.</p> 302 </blockquote> 303 <div class="box"><em>End of informative text.</em></div> 304 <hr> 305 <p> </p> 306 <a href="#top"><span class="topOfPage">return to top of page</span></a><br> 307 <hr size="2" noshade> 308 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br> 309 POSIX™ is a Trademark of The IEEE.<br> 310 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br> 311 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href= 312 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a> 313 ]</font></center> 314 <hr size="2" noshade> 315 <div class="NAVHEADER"> 316 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 317 <tr class="nav"> 318 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/ipcs.html" accesskey="P"><<< 319 Previous</a></td> 320 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 321 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/join.html" accesskey="N">Next >>></a></td> 322 </tr> 323 </table> 324 <hr align="left" width="100%"></div> 325 </body> 326 </html>