RETURN VALUE
If command is a null pointer, system() shall return non-zero to indicate that a command processor is avail-
able, or zero if none is available. The system() function shall always return non-zero when command is NULL.
If command is not a null pointer, system() shall return the
termination status of the command language inter-
preter in the format specified by waitpid(). The termination status shall be as defined for the 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) or _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 -1 and
set errno to indicate the error.
ERRORS
The system() function may set errno values as described by fork() .
In addition, system() may fail if:
ECHILD The status of the child process created by system() is no longer available.
The following sections are informative.
EXAMPLES
None.
APPLICATION USAGE
If the return value of system() is not -1, its value can be decoded through the use of the macros described in
<sys/wait.h>. For convenience, these macros are also provided in <stdlib.h>.
Partager