| <html lang="en"> |
| <head> |
| <title>system - 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="Stdlib.html#Stdlib" title="Stdlib"> |
| <link rel="prev" href="wcstoull.html#wcstoull" title="wcstoull"> |
| <link rel="next" href="wcstombs.html#wcstombs" title="wcstombs"> |
| <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="system"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="wcstombs.html#wcstombs">wcstombs</a>, |
| Previous: <a rel="previous" accesskey="p" href="wcstoull.html#wcstoull">wcstoull</a>, |
| Up: <a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">2.45 <code>system</code>—execute command string</h3> |
| |
| <p><a name="index-system-106"></a><a name="index-g_t_005fsystem_005fr-107"></a><strong>Synopsis</strong> |
| <pre class="example"> #include <stdlib.h> |
| int system(char *<var>s</var>); |
| |
| int _system_r(void *<var>reent</var>, char *<var>s</var>); |
| |
| </pre> |
| <p><strong>Description</strong><br> |
| |
| <p>Use <code>system</code> to pass a command string <code>*</code><var>s</var> to <code>/bin/sh</code> on |
| your system, and wait for it to finish executing. |
| |
| <p>Use “<code>system(NULL)</code>” to test whether your system has <code>/bin/sh</code> |
| available. |
| |
| <p>The alternate function <code>_system_r</code> is a reentrant version. The |
| extra argument <var>reent</var> is a pointer to a reentrancy structure. |
| |
| <p><br> |
| <strong>Returns</strong><br> |
| <code>system(NULL)</code> returns a non-zero value if <code>/bin/sh</code> is available, and |
| <code>0</code> if it is not. |
| |
| <p>With a command argument, the result of <code>system</code> is the exit status |
| returned by <code>/bin/sh</code>. |
| |
| <p><br> |
| <strong>Portability</strong><br> |
| ANSI C requires <code>system</code>, but leaves the nature and effects of a |
| command processor undefined. ANSI C does, however, specify that |
| <code>system(NULL)</code> return zero or nonzero to report on the existence of |
| a command processor. |
| |
| <p>POSIX.2 requires <code>system</code>, and requires that it invoke a <code>sh</code>. |
| Where <code>sh</code> is found is left unspecified. |
| |
| <p>Supporting OS subroutines required: <code>_exit</code>, <code>_execve</code>, <code>_fork_r</code>, |
| <code>_wait_r</code>. |
| |
| <p><br> |
| |
| </body></html> |
| |