system(3S)
NAME
system − issue a shell command
SYNOPSIS
#include <stdlib.h>
int system(const char ∗string);
MT-LEVEL
Unsafe
DESCRIPTION
system() causes the string to be given to the shell as input, as if the 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 non-zero; otherwise it returns zero.
Solaris system() uses /usr/bin/sh (see sh(1)).
XPG4 system() uses the XPG4-compliant shell /usr/bin/ksh (see ksh(1)).
RETURN VALUES
system() forks to create a child process that in turn execs the shell in order to execute string. If the fork() or exec() fails, system() returns a value of −1 and sets errno.
ERRORS
system() fails if one or more of the following are true:
EAGAIN The system-imposed limit on the total number of processes under execution by a single user would be exceeded.
EINTR system() was interrupted by a signal.
ENOMEM The new process requires more memory than is available.
SEE ALSO
ksh(1), sh(1), useradd(1M), exec(2), fork(2), setuid(2), waitpid(2), xpg4(5)
NOTES
system() 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)).
SunOS 5.5.1 — Last change: 17 Jul 1995