int system(const char *command);
IEEE Std 1003.1-2017
If command is a
null pointer, the
system() function shall determine whether the host environment has a command
processor. If command is not a
null pointer, the
system() function shall pass the string pointed to by command
to that command processor to be executed in an implementation-defined manner; this might then cause the program calling
system() to behave in a non-conforming manner or to terminate.
system() function shall behave as if a child process were created using
and the child process invoked the
sh utility using
execl() as follows:
execl(<shell path>, "sh", "-c", command, (char *)0);
<shell path> is an unspecified pathname for the sh utility. It is
unspecified whether the handlers registered with
pthread_atfork() are called
as part of the creation of the child process.
system() function shall ignore the
SIGQUIT signals, and shall block the
SIGCHLD signal, while waiting for
the command to terminate. If this might cause the application to miss a signal that would have killed it, then the application
should examine the return value from
system() and take whatever action is appropriate to the application if the command
terminated due to receipt of a signal.
system() function shall not affect the termination status of any child of the calling processes other than the
process or processes it itself creates.
system() function shall not return until the child process has terminated.
system() function need not be thread-safe.
If command is a null pointer,
system() shall return non-zero to indicate that a command processor is available, or
zero if none is available. The
system() function shall always return non-zero when command is
command is not a null pointer,
system() shall return the termination status of the command language interpreter in
the format specified by
waitpid(). The termination status shall be as defined for
sh utility; otherwise, the termination status is unspecified. If some error prevents
the command language interpreter from executing after the child process is created, the return value from
system() shall be
as if the command language interpreter had terminated using
_exit(127). If a child process cannot be
created, or if the termination status for the command language interpreter cannot be obtained,
system() shall return
errno to indicate the error.
system() function may set
errno values as described by
system() may fail if:
ECHILD- The status of the child process created by
system()is no longer available.