pass a command to the shell

You're viewing an older version of this page (#3294). View the current version.

View versions (3)

NAME

<span class="Nm" id="system">system</span>

INTERFACE

#include <stdlib.h> int system ( const char *string )

DESCRIPTION

The system function hands the argument &#92;c string to the command interpreter reference:sh (1) . The calling process waits for the shell to finish executing the command, ignoring <span class="Dv">SIGINT</span> and <span class="Dv">SIGQUIT</span>, and blocking <span class="Dv">SIGCHLD</span>. &#92;n &#92;n If &#92;c string is a <span class="Dv">NULL</span> pointer, system will return non-zero if the command interpreter reference:sh (1) is available, and zero if it is not. &#92;n &#92;n The system function returns the exit status of the shell as returned by reference:waitpid (2) , or -1 if an error occurred when invoking reference:fork (2) or reference:waitpid (2) . A return value of 127 means the execution of the shell failed.

SEE ALSO

reference:sh (1) , reference:execve (2) , reference:fork (2) , reference:waitpid (2) , reference:popen (3)

STANDARDS

The system function conforms to and is expected to be compatible.