<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.13"> <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"> <a name="Controlling-Subprocesses"></a> <p> 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>