1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595
|
<html lang="en">
<head>
<title>Controlling Subprocesses - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.11">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="System-Utilities.html#System-Utilities" title="System Utilities">
<link rel="prev" href="Networking-Utilities.html#Networking-Utilities" title="Networking Utilities">
<link rel="next" href="Process-ID-Information.html#Process-ID-Information" title="Process ID Information">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<p>
<a name="Controlling-Subprocesses"></a>
Next: <a rel="next" accesskey="n" href="Process-ID-Information.html#Process-ID-Information">Process ID Information</a>,
Previous: <a rel="previous" accesskey="p" href="Networking-Utilities.html#Networking-Utilities">Networking Utilities</a>,
Up: <a rel="up" accesskey="u" href="System-Utilities.html#System-Utilities">System Utilities</a>
<hr>
</div>
<h3 class="section">34.5 Controlling Subprocesses</h3>
<p>Octave includes some high-level commands like <code>system</code> and
<code>popen</code> for starting subprocesses. If you want to run another
program to perform some task and then look at its output, you will
probably want to use these functions.
<p>Octave also provides several very low-level Unix-like functions which
can also be used for starting subprocesses, but you should probably only
use them if you can't find any way to do what you need with the
higher-level functions.
<!-- toplev.cc -->
<p><a name="doc_002dsystem"></a>
<div class="defun">
— Built-in Function: <b>system</b> (<var>string, return_output, type</var>)<var><a name="index-system-2371"></a></var><br>
<blockquote><p>Execute a shell command specified by <var>string</var>. The second
argument is optional. If <var>type</var> is <code>"async"</code>, the process
is started in the background and the process id of the child process
is returned immediately. Otherwise, the process is started, and
Octave waits until it exits. If the <var>type</var> argument is omitted, a
value of <code>"sync"</code> is assumed.
<p>If two input arguments are given (the actual value of
<var>return_output</var> is irrelevant) and the subprocess is started
synchronously, or if <var>system</var> is called with one input argument and
one or more output arguments, the output from the command is returned.
Otherwise, if the subprocess is executed synchronously, its output is
sent to the standard output. To send the output of a command executed
with <var>system</var> through the pager, use a command like
<pre class="example"> disp (system (cmd, 1));
</pre>
<p class="noindent">or
<pre class="example"> printf ("%s\n", system (cmd, 1));
</pre>
<p>The <code>system</code> function can return two values. The first is the
exit status of the command and the second is any output from the
command that was written to the standard output stream. For example,
<pre class="example"> [status, output] = system ("echo foo; exit 2");
</pre>
<p class="noindent">will set the variable <code>output</code> to the string ‘<samp><span class="samp">foo</span></samp>’, and the
variable <code>status</code> to the integer ‘<samp><span class="samp">2</span></samp>’.
</p></blockquote></div>
<!-- ./miscellaneous/unix.m -->
<p><a name="doc_002dunix"></a>
<div class="defun">
— Function File: [<var>status</var>, <var>text</var>] <b>unix</b> (<var>command</var>)<var><a name="index-unix-2372"></a></var><br>
— Function File: [<var>status</var>, <var>text</var>] <b>unix</b> (<var>command, "-echo"</var>)<var><a name="index-unix-2373"></a></var><br>
<blockquote><p>Execute a system command if running under a Unix-like operating
system, otherwise do nothing. Return the exit status of the program
in <var>status</var> and any output sent to the standard output in
<var>text</var>. If the optional second argument <code>"-echo"</code> is given,
then also send the output from the command to the standard output.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002disunix.html#doc_002disunix">isunix</a>, <a href="doc_002dispc.html#doc_002dispc">ispc</a>, <a href="doc_002dsystem.html#doc_002dsystem">system</a>.
</p></blockquote></div>
<!-- ./miscellaneous/dos.m -->
<p><a name="doc_002ddos"></a>
<div class="defun">
— Function File: [<var>status</var>, <var>text</var>] = <b>dos</b> (<var>command</var>)<var><a name="index-dos-2374"></a></var><br>
— Function File: [<var>status</var>, <var>text</var>] = <b>dos</b> (<var>command, "-echo"</var>)<var><a name="index-dos-2375"></a></var><br>
<blockquote><p>Execute a system command if running under a Windows-like operating
system, otherwise do nothing. Return the exit status of the program
in <var>status</var> and any output sent to the standard output in
<var>text</var>. If the optional second argument <code>"-echo"</code> is given,
then also send the output from the command to the standard output.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dunix.html#doc_002dunix">unix</a>, <a href="doc_002disunix.html#doc_002disunix">isunix</a>, <a href="doc_002dispc.html#doc_002dispc">ispc</a>, <a href="doc_002dsystem.html#doc_002dsystem">system</a>.
</p></blockquote></div>
<!-- ./miscellaneous/perl.m -->
<p><a name="doc_002dperl"></a>
<div class="defun">
— Function File: [<var>output</var>, <var>status</var>] = <b>perl</b> (<var>scriptfile</var>)<var><a name="index-perl-2376"></a></var><br>
— Function File: [<var>output</var>, <var>status</var>] = <b>perl</b> (<var>scriptfile, argument1, argument2, <small class="dots">...</small></var>)<var><a name="index-perl-2377"></a></var><br>
<blockquote><p>Invoke perl script <var>scriptfile</var> with possibly a list of
command line arguments.
Returns output in <var>output</var> and status
in <var>status</var>.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dsystem.html#doc_002dsystem">system</a>.
</p></blockquote></div>
<!-- file-io.cc -->
<p><a name="doc_002dpopen"></a>
<div class="defun">
— Built-in Function: <var>fid</var> = <b>popen</b> (<var>command, mode</var>)<var><a name="index-popen-2378"></a></var><br>
<blockquote><p>Start a process and create a pipe. The name of the command to run is
given by <var>command</var>. The file identifier corresponding to the input
or output stream of the process is returned in <var>fid</var>. The argument
<var>mode</var> may be
<dl>
<dt><code>"r"</code><dd>The pipe will be connected to the standard output of the process, and
open for reading.
<br><dt><code>"w"</code><dd>The pipe will be connected to the standard input of the process, and
open for writing.
</dl>
<p>For example,
<pre class="example"> fid = popen ("ls -ltr / | tail -3", "r");
while (ischar (s = fgets (fid)))
fputs (stdout, s);
endwhile
-| drwxr-xr-x 33 root root 3072 Feb 15 13:28 etc
-| drwxr-xr-x 3 root root 1024 Feb 15 13:28 lib
-| drwxrwxrwt 15 root root 2048 Feb 17 14:53 tmp
</pre>
</blockquote></div>
<!-- file-io.cc -->
<p><a name="doc_002dpclose"></a>
<div class="defun">
— Built-in Function: <b>pclose</b> (<var>fid</var>)<var><a name="index-pclose-2379"></a></var><br>
<blockquote><p>Close a file identifier that was opened by <code>popen</code>. You may also
use <code>fclose</code> for the same purpose.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dpopen2"></a>
<div class="defun">
— Built-in Function: [<var>in</var>, <var>out</var>, <var>pid</var>] = <b>popen2</b> (<var>command, args</var>)<var><a name="index-popen2-2380"></a></var><br>
<blockquote><p>Start a subprocess with two-way communication. The name of the process
is given by <var>command</var>, and <var>args</var> is an array of strings
containing options for the command. The file identifiers for the input
and output streams of the subprocess are returned in <var>in</var> and
<var>out</var>. If execution of the command is successful, <var>pid</var>
contains the process ID of the subprocess. Otherwise, <var>pid</var> is
−1.
<p>For example,
<pre class="example"> [in, out, pid] = popen2 ("sort", "-r");
fputs (in, "these\nare\nsome\nstrings\n");
fclose (in);
EAGAIN = errno ("EAGAIN");
done = false;
do
s = fgets (out);
if (ischar (s))
fputs (stdout, s);
elseif (errno () == EAGAIN)
sleep (0.1);
fclear (out);
else
done = true;
endif
until (done)
fclose (out);
waitpid (pid);
-| these
-| strings
-| some
-| are
</pre>
<p>Note that <code>popen2</code>, unlike <code>popen</code>, will not "reap" the
child process. If you don't use <code>waitpid</code> to check the child's
exit status, it will linger until Octave exits.
</p></blockquote></div>
<!-- defaults.cc -->
<p><a name="doc_002dEXEC_005fPATH"></a>
<div class="defun">
— Built-in Function: <var>val</var> = <b>EXEC_PATH</b> ()<var><a name="index-EXEC_005fPATH-2381"></a></var><br>
— Built-in Function: <var>old_val</var> = <b>EXEC_PATH</b> (<var>new_val</var>)<var><a name="index-EXEC_005fPATH-2382"></a></var><br>
<blockquote><p>Query or set the internal variable that specifies a colon separated
list of directories to search when executing external programs.
Its initial value is taken from the environment variable
<code>OCTAVE_EXEC_PATH</code><!-- /@w --> (if it exists) or <code>PATH</code>, but that
value can be overridden by the command line argument
<code>--exec-path PATH</code>. At startup, an additional set of
directories (including the shell PATH) is appended to the path
specified in the environment or on the command line. If you use
the <code>EXEC_PATH</code><!-- /@w --> function to modify the path, you should take
care to preserve these additional directories.
</p></blockquote></div>
<p>In most cases, the following functions simply decode their arguments and
make the corresponding Unix system calls. For a complete example of how
they can be used, look at the definition of the function <code>popen2</code>.
<!-- syscalls.cc -->
<p><a name="doc_002dfork"></a>
<div class="defun">
— Built-in Function: [<var>pid</var>, <var>msg</var>] = <b>fork</b> ()<var><a name="index-fork-2383"></a></var><br>
<blockquote><p>Create a copy of the current process.
<p>Fork can return one of the following values:
<dl>
<dt>> 0<dd>You are in the parent process. The value returned from <code>fork</code> is
the process id of the child process. You should probably arrange to
wait for any child processes to exit.
<br><dt>0<dd>You are in the child process. You can call <code>exec</code> to start another
process. If that fails, you should probably call <code>exit</code>.
<br><dt>< 0<dd>The call to <code>fork</code> failed for some reason. You must take evasive
action. A system dependent error message will be waiting in <var>msg</var>.
</dl>
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dexec"></a>
<div class="defun">
— Built-in Function: [<var>err</var>, <var>msg</var>] = <b>exec</b> (<var>file, args</var>)<var><a name="index-exec-2384"></a></var><br>
<blockquote><p>Replace current process with a new process. Calling <code>exec</code> without
first calling <code>fork</code> will terminate your current Octave process and
replace it with the program named by <var>file</var>. For example,
<pre class="example"> exec ("ls" "-l")
</pre>
<p class="noindent">will run <code>ls</code> and return you to your shell prompt.
<p>If successful, <code>exec</code> does not return. If <code>exec</code> does return,
<var>err</var> will be nonzero, and <var>msg</var> will contain a system-dependent
error message.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dpipe"></a>
<div class="defun">
— Built-in Function: [<var>read_fd</var>, <var>write_fd</var>, <var>err</var>, <var>msg</var>] = <b>pipe</b> ()<var><a name="index-pipe-2385"></a></var><br>
<blockquote><p>Create a pipe and return the reading and writing ends of the pipe
into <var>read_fd</var> and <var>write_fd</var> respectively.
<p>If successful, <var>err</var> is 0 and <var>msg</var> is an empty string.
Otherwise, <var>err</var> is nonzero and <var>msg</var> contains a
system-dependent error message.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002ddup2"></a>
<div class="defun">
— Built-in Function: [<var>fid</var>, <var>msg</var>] = <b>dup2</b> (<var>old, new</var>)<var><a name="index-dup2-2386"></a></var><br>
<blockquote><p>Duplicate a file descriptor.
<p>If successful, <var>fid</var> is greater than zero and contains the new file
ID. Otherwise, <var>fid</var> is negative and <var>msg</var> contains a
system-dependent error message.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dwaitpid"></a>
<div class="defun">
— Built-in Function: [<var>pid</var>, <var>status</var>, <var>msg</var>] = <b>waitpid</b> (<var>pid, options</var>)<var><a name="index-waitpid-2387"></a></var><br>
<blockquote><p>Wait for process <var>pid</var> to terminate. The <var>pid</var> argument can be:
<dl>
<dt>−1<dd>Wait for any child process.
<br><dt>0<dd>Wait for any child process whose process group ID is equal to that of
the Octave interpreter process.
<br><dt>> 0<dd>Wait for termination of the child process with ID <var>pid</var>.
</dl>
<p>The <var>options</var> argument can be a bitwise OR of zero or more of
the following constants:
<dl>
<dt><code>0</code><dd>Wait until signal is received or a child process exits (this is the
default if the <var>options</var> argument is missing).
<br><dt><code>WNOHANG</code><dd>Do not hang if status is not immediately available.
<br><dt><code>WUNTRACED</code><dd>Report the status of any child processes that are stopped, and whose
status has not yet been reported since they stopped.
<br><dt><code>WCONTINUE</code><dd>Return if a stopped child has been resumed by delivery of <code>SIGCONT</code>.
This value may not be meaningful on all systems.
</dl>
<p>If the returned value of <var>pid</var> is greater than 0, it is the process
ID of the child process that exited. If an error occurs, <var>pid</var> will
be less than zero and <var>msg</var> will contain a system-dependent error
message. The value of <var>status</var> contains additional system-dependent
information about the subprocess that exited.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dWCONTINUE.html#doc_002dWCONTINUE">WCONTINUE</a>, <a href="doc_002dWCOREDUMP.html#doc_002dWCOREDUMP">WCOREDUMP</a>, <a href="doc_002dWEXITSTATUS.html#doc_002dWEXITSTATUS">WEXITSTATUS</a>, <a href="doc_002dWIFCONTINUED.html#doc_002dWIFCONTINUED">WIFCONTINUED</a>, <a href="doc_002dWIFSIGNALED.html#doc_002dWIFSIGNALED">WIFSIGNALED</a>, <a href="doc_002dWIFSTOPPED.html#doc_002dWIFSTOPPED">WIFSTOPPED</a>, <a href="doc_002dWNOHANG.html#doc_002dWNOHANG">WNOHANG</a>, <a href="doc_002dWSTOPSIG.html#doc_002dWSTOPSIG">WSTOPSIG</a>, <a href="doc_002dWTERMSIG.html#doc_002dWTERMSIG">WTERMSIG</a>, <a href="doc_002dWUNTRACED.html#doc_002dWUNTRACED">WUNTRACED</a>.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dWCONTINUE"></a>
<div class="defun">
— Built-in Function: WCONINTUE <b>(</b>)<var><a name="index-g_t_0028-2388"></a></var><br>
<blockquote><p>Return the numerical value of the option argument that may be
passed to <code>waitpid</code> to indicate that it should also return
if a stopped child has been resumed by delivery of a <code>SIGCONT</code>
signal.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dwaitpid.html#doc_002dwaitpid">waitpid</a>, <a href="doc_002dWNOHANG.html#doc_002dWNOHANG">WNOHANG</a>, <a href="doc_002dWUNTRACED.html#doc_002dWUNTRACED">WUNTRACED</a>.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dWCOREDUMP"></a>
<div class="defun">
— Built-in Function: <b>WCOREDUMP</b> (<var>status</var>)<var><a name="index-WCOREDUMP-2389"></a></var><br>
<blockquote><p>Given <var>status</var> from a call to <code>waitpid</code>, return true if the
child produced a core dump. This function should only be employed if
<code>WIFSIGNALED</code> returned true. The macro used to implement this
function is not specified in POSIX.1-2001 and is not available on some
Unix implementations (e.g., AIX, SunOS).
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dwaitpid.html#doc_002dwaitpid">waitpid</a>, <a href="doc_002dWIFEXITED.html#doc_002dWIFEXITED">WIFEXITED</a>, <a href="doc_002dWEXITSTATUS.html#doc_002dWEXITSTATUS">WEXITSTATUS</a>, <a href="doc_002dWIFSIGNALED.html#doc_002dWIFSIGNALED">WIFSIGNALED</a>, <a href="doc_002dWTERMSIG.html#doc_002dWTERMSIG">WTERMSIG</a>, <a href="doc_002dWIFSTOPPED.html#doc_002dWIFSTOPPED">WIFSTOPPED</a>, <a href="doc_002dWSTOPSIG.html#doc_002dWSTOPSIG">WSTOPSIG</a>, <a href="doc_002dWIFCONTINUED.html#doc_002dWIFCONTINUED">WIFCONTINUED</a>.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dWEXITSTATUS"></a>
<div class="defun">
— Built-in Function: <b>WEXITSTATUS</b> (<var>status</var>)<var><a name="index-WEXITSTATUS-2390"></a></var><br>
<blockquote><p>Given <var>status</var> from a call to <code>waitpid</code>, return the exit
status of the child. This function should only be employed if
<code>WIFEXITED</code> returned true.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dwaitpid.html#doc_002dwaitpid">waitpid</a>, <a href="doc_002dWIFEXITED.html#doc_002dWIFEXITED">WIFEXITED</a>, <a href="doc_002dWIFSIGNALED.html#doc_002dWIFSIGNALED">WIFSIGNALED</a>, <a href="doc_002dWTERMSIG.html#doc_002dWTERMSIG">WTERMSIG</a>, <a href="doc_002dWCOREDUMP.html#doc_002dWCOREDUMP">WCOREDUMP</a>, <a href="doc_002dWIFSTOPPED.html#doc_002dWIFSTOPPED">WIFSTOPPED</a>, <a href="doc_002dWSTOPSIG.html#doc_002dWSTOPSIG">WSTOPSIG</a>, <a href="doc_002dWIFCONTINUED.html#doc_002dWIFCONTINUED">WIFCONTINUED</a>.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dWIFCONTINUED"></a>
<div class="defun">
— Built-in Function: <b>WIFCONTINUED</b> (<var>status</var>)<var><a name="index-WIFCONTINUED-2391"></a></var><br>
<blockquote><p>Given <var>status</var> from a call to <code>waitpid</code>, return true if the
child process was resumed by delivery of <code>SIGCONT</code>.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dwaitpid.html#doc_002dwaitpid">waitpid</a>, <a href="doc_002dWIFEXITED.html#doc_002dWIFEXITED">WIFEXITED</a>, <a href="doc_002dWEXITSTATUS.html#doc_002dWEXITSTATUS">WEXITSTATUS</a>, <a href="doc_002dWIFSIGNALED.html#doc_002dWIFSIGNALED">WIFSIGNALED</a>, <a href="doc_002dWTERMSIG.html#doc_002dWTERMSIG">WTERMSIG</a>, <a href="doc_002dWCOREDUMP.html#doc_002dWCOREDUMP">WCOREDUMP</a>, <a href="doc_002dWIFSTOPPED.html#doc_002dWIFSTOPPED">WIFSTOPPED</a>, <a href="doc_002dWSTOPSIG.html#doc_002dWSTOPSIG">WSTOPSIG</a>.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dWIFSIGNALED"></a>
<div class="defun">
— Built-in Function: <b>WIFSIGNALED</b> (<var>status</var>)<var><a name="index-WIFSIGNALED-2392"></a></var><br>
<blockquote><p>Given <var>status</var> from a call to <code>waitpid</code>, return true if the
child process was terminated by a signal.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dwaitpid.html#doc_002dwaitpid">waitpid</a>, <a href="doc_002dWIFEXITED.html#doc_002dWIFEXITED">WIFEXITED</a>, <a href="doc_002dWEXITSTATUS.html#doc_002dWEXITSTATUS">WEXITSTATUS</a>, <a href="doc_002dWTERMSIG.html#doc_002dWTERMSIG">WTERMSIG</a>, <a href="doc_002dWCOREDUMP.html#doc_002dWCOREDUMP">WCOREDUMP</a>, <a href="doc_002dWIFSTOPPED.html#doc_002dWIFSTOPPED">WIFSTOPPED</a>, <a href="doc_002dWSTOPSIG.html#doc_002dWSTOPSIG">WSTOPSIG</a>, <a href="doc_002dWIFCONTINUED.html#doc_002dWIFCONTINUED">WIFCONTINUED</a>.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dWIFSTOPPED"></a>
<div class="defun">
— Built-in Function: <b>WIFSTOPPED</b> (<var>status</var>)<var><a name="index-WIFSTOPPED-2393"></a></var><br>
<blockquote><p>Given <var>status</var> from a call to <code>waitpid</code>, return true if the
child process was stopped by delivery of a signal; this is only
possible if the call was done using <code>WUNTRACED</code> or when the child
is being traced (see ptrace(2)).
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dwaitpid.html#doc_002dwaitpid">waitpid</a>, <a href="doc_002dWIFEXITED.html#doc_002dWIFEXITED">WIFEXITED</a>, <a href="doc_002dWEXITSTATUS.html#doc_002dWEXITSTATUS">WEXITSTATUS</a>, <a href="doc_002dWIFSIGNALED.html#doc_002dWIFSIGNALED">WIFSIGNALED</a>, <a href="doc_002dWTERMSIG.html#doc_002dWTERMSIG">WTERMSIG</a>, <a href="doc_002dWCOREDUMP.html#doc_002dWCOREDUMP">WCOREDUMP</a>, <a href="doc_002dWSTOPSIG.html#doc_002dWSTOPSIG">WSTOPSIG</a>, <a href="doc_002dWIFCONTINUED.html#doc_002dWIFCONTINUED">WIFCONTINUED</a>.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dWIFEXITED"></a>
<div class="defun">
— Built-in Function: <b>WIFEXITED</b> (<var>status</var>)<var><a name="index-WIFEXITED-2394"></a></var><br>
<blockquote><p>Given <var>status</var> from a call to <code>waitpid</code>, return true if the
child terminated normally.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dwaitpid.html#doc_002dwaitpid">waitpid</a>, <a href="doc_002dWEXITSTATUS.html#doc_002dWEXITSTATUS">WEXITSTATUS</a>, <a href="doc_002dWIFSIGNALED.html#doc_002dWIFSIGNALED">WIFSIGNALED</a>, <a href="doc_002dWTERMSIG.html#doc_002dWTERMSIG">WTERMSIG</a>, <a href="doc_002dWCOREDUMP.html#doc_002dWCOREDUMP">WCOREDUMP</a>, <a href="doc_002dWIFSTOPPED.html#doc_002dWIFSTOPPED">WIFSTOPPED</a>, <a href="doc_002dWSTOPSIG.html#doc_002dWSTOPSIG">WSTOPSIG</a>, <a href="doc_002dWIFCONTINUED.html#doc_002dWIFCONTINUED">WIFCONTINUED</a>.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dWNOHANG"></a>
<div class="defun">
— Built-in Function: <b>WNOHANG</b> ()<var><a name="index-WNOHANG-2395"></a></var><br>
<blockquote><p>Return the numerical value of the option argument that may be
passed to <code>waitpid</code> to indicate that it should return its
status immediately instead of waiting for a process to exit.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dwaitpid.html#doc_002dwaitpid">waitpid</a>, <a href="doc_002dWUNTRACED.html#doc_002dWUNTRACED">WUNTRACED</a>, <a href="doc_002dWCONTINUE.html#doc_002dWCONTINUE">WCONTINUE</a>.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dWSTOPSIG"></a>
<div class="defun">
— Built-in Function: <b>WSTOPSIG</b> (<var>status</var>)<var><a name="index-WSTOPSIG-2396"></a></var><br>
<blockquote><p>Given <var>status</var> from a call to <code>waitpid</code>, return the number of
the signal which caused the child to stop. This function should only
be employed if <code>WIFSTOPPED</code> returned true.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dwaitpid.html#doc_002dwaitpid">waitpid</a>, <a href="doc_002dWIFEXITED.html#doc_002dWIFEXITED">WIFEXITED</a>, <a href="doc_002dWEXITSTATUS.html#doc_002dWEXITSTATUS">WEXITSTATUS</a>, <a href="doc_002dWIFSIGNALED.html#doc_002dWIFSIGNALED">WIFSIGNALED</a>, <a href="doc_002dWTERMSIG.html#doc_002dWTERMSIG">WTERMSIG</a>, <a href="doc_002dWCOREDUMP.html#doc_002dWCOREDUMP">WCOREDUMP</a>, <a href="doc_002dWIFSTOPPED.html#doc_002dWIFSTOPPED">WIFSTOPPED</a>, <a href="doc_002dWIFCONTINUED.html#doc_002dWIFCONTINUED">WIFCONTINUED</a>.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dWTERMSIG"></a>
<div class="defun">
— Built-in Function: <b>WTERMSIG</b> (<var>status</var>)<var><a name="index-WTERMSIG-2397"></a></var><br>
<blockquote><p>Given <var>status</var> from a call to <code>waitpid</code>, return the number of
the signal that caused the child process to terminate. This function
should only be employed if <code>WIFSIGNALED</code> returned true.
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dwaitpid.html#doc_002dwaitpid">waitpid</a>, <a href="doc_002dWIFEXITED.html#doc_002dWIFEXITED">WIFEXITED</a>, <a href="doc_002dWEXITSTATUS.html#doc_002dWEXITSTATUS">WEXITSTATUS</a>, <a href="doc_002dWIFSIGNALED.html#doc_002dWIFSIGNALED">WIFSIGNALED</a>, <a href="doc_002dWCOREDUMP.html#doc_002dWCOREDUMP">WCOREDUMP</a>, <a href="doc_002dWIFSTOPPED.html#doc_002dWIFSTOPPED">WIFSTOPPED</a>, <a href="doc_002dWSTOPSIG.html#doc_002dWSTOPSIG">WSTOPSIG</a>, <a href="doc_002dWIFCONTINUED.html#doc_002dWIFCONTINUED">WIFCONTINUED</a>.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dWUNTRACED"></a>
<div class="defun">
— Built-in Function: <b>WUNTRACED</b> ()<var><a name="index-WUNTRACED-2398"></a></var><br>
<blockquote><p>Return the numerical value of the option argument that may be
passed to <code>waitpid</code> to indicate that it should also return
if the child process has stopped but is not traced via the
<code>ptrace</code> system call
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->
<p class="noindent"><strong>See also:</strong> <a href="doc_002dwaitpid.html#doc_002dwaitpid">waitpid</a>, <a href="doc_002dWNOHANG.html#doc_002dWNOHANG">WNOHANG</a>, <a href="doc_002dWCONTINUE.html#doc_002dWCONTINUE">WCONTINUE</a>.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dfcntl"></a>
<div class="defun">
— Built-in Function: [<var>err</var>, <var>msg</var>] = <b>fcntl</b> (<var>fid, request, arg</var>)<var><a name="index-fcntl-2399"></a></var><br>
<blockquote><p>Change the properties of the open file <var>fid</var>. The following values
may be passed as <var>request</var>:
<dl>
<dt><code>F_DUPFD</code><a name="index-F_005fDUPFD-2400"></a><dd>Return a duplicate file descriptor.
<br><dt><code>F_GETFD</code><a name="index-F_005fGETFD-2401"></a><dd>Return the file descriptor flags for <var>fid</var>.
<br><dt><code>F_SETFD</code><a name="index-F_005fSETFD-2402"></a><dd>Set the file descriptor flags for <var>fid</var>.
<br><dt><code>F_GETFL</code><a name="index-F_005fGETFL-2403"></a><dd>Return the file status flags for <var>fid</var>. The following codes may be
returned (some of the flags may be undefined on some systems).
<dl>
<dt><code>O_RDONLY</code><a name="index-O_005fRDONLY-2404"></a><dd>Open for reading only.
<br><dt><code>O_WRONLY</code><a name="index-O_005fWRONLY-2405"></a><dd>Open for writing only.
<br><dt><code>O_RDWR</code><a name="index-O_005fRDWR-2406"></a><dd>Open for reading and writing.
<br><dt><code>O_APPEND</code><a name="index-O_005fAPPEND-2407"></a><dd>Append on each write.
<br><dt><code>O_CREAT</code><a name="index-O_005fCREAT-2408"></a><dd>Create the file if it does not exist.
<br><dt><code>O_NONBLOCK</code><a name="index-O_005fNONBLOCK-2409"></a><dd>Nonblocking mode.
<br><dt><code>O_SYNC</code><a name="index-O_005fSYNC-2410"></a><dd>Wait for writes to complete.
<br><dt><code>O_ASYNC</code><a name="index-O_005fASYNC-2411"></a><dd>Asynchronous I/O.
</dl>
<br><dt><code>F_SETFL</code><a name="index-F_005fSETFL-2412"></a><dd>Set the file status flags for <var>fid</var> to the value specified by
<var>arg</var>. The only flags that can be changed are <code>O_APPEND</code><!-- /@w --> and
<code>O_NONBLOCK</code><!-- /@w -->.
</dl>
<p>If successful, <var>err</var> is 0 and <var>msg</var> is an empty string.
Otherwise, <var>err</var> is nonzero and <var>msg</var> contains a
system-dependent error message.
</p></blockquote></div>
<!-- syscalls.cc -->
<p><a name="doc_002dkill"></a>
<div class="defun">
— Built-in Function: [<var>err</var>, <var>msg</var>] = <b>kill</b> (<var>pid, sig</var>)<var><a name="index-kill-2413"></a></var><br>
<blockquote><p>Send signal <var>sig</var> to process <var>pid</var>.
<p>If <var>pid</var> is positive, then signal <var>sig</var> is sent to <var>pid</var>.
<p>If <var>pid</var> is 0, then signal <var>sig</var> is sent to every process
in the process group of the current process.
<p>If <var>pid</var> is -1, then signal <var>sig</var> is sent to every process
except process 1.
<p>If <var>pid</var> is less than -1, then signal <var>sig</var> is sent to every
process in the process group <var>-pid</var>.
<p>If <var>sig</var> is 0, then no signal is sent, but error checking is still
performed.
<p>Return 0 if successful, otherwise return -1.
</p></blockquote></div>
<!-- sighandlers.cc -->
<p><a name="doc_002dSIG"></a>
<div class="defun">
— Built-in Function: <b>SIG</b> ()<var><a name="index-SIG-2414"></a></var><br>
<blockquote><p>Return a structure containing Unix signal names and their defined values.
</p></blockquote></div>
</body></html>
|