This function executes command as a shell command. In the GNU C
library, it always uses the default shell sh
to run the command.
In particular, it searches the directories in PATH
to find
programs to execute. The return value is -1
if it wasn't
possible to create the shell process, and otherwise is the status of the
shell process. See Process Completion, for details on how this
status code can be interpreted.
If the command argument is a null pointer, a return value of zero
indicates that no command processor is available.
This function is a cancellation point in multi-threaded programs. This
is a problem if the thread allocates some resources (like memory, file
descriptors, semaphores or whatever) at the time system
is
called. If the thread gets canceled these resources stay allocated
until the program ends. To avoid this calls to system
should be
protected using cancellation handlers.
The system
function is declared in the header file
stdlib.h.