NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | USAGE | ATTRIBUTES | SEE ALSO
#include <stdlib.h>int system(const char *string);
The system() function causes string to be given to the shell as input, as if string had been typed as a command at a terminal. The invoker waits until the shell has completed, then returns the exit status of the shell in the format specified by waitpid(2).
If string is a null pointer, system() checks if the shell exists and is executable. If the shell is available, system() returns a non-zero value; otherwise, it returns 0. If the application is standard-conforming (see standards(5)), system() uses /usr/bin/ksh (see ksh(1)); otherwise system() uses /usr/bin/sh (see sh(1)).
The system() function forks to create a child process that in turn invokes one of the exec family of functions (see exec(2)) on the shell to execute string. If fork() or the exec function fails, system() returns -1 and sets errno to indicate the error.
The system() function fails if:
The system-imposed limit on the total number of processes under execution by a single user would be exceeded.
The system() function was interrupted by a signal.
The new process requires more memory than is available.
The system() function will fail to execute setuid() or setgid() if either the UID or GID of the application's owner/group is less than 100. See useradd(1M) and setuid(2).
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
MT-Level | Unsafe |
NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | USAGE | ATTRIBUTES | SEE ALSO