system

 


 
 
 
 Standard C Library Functions                           system(3C)
 
 
 


NAME

system - issue a shell command

SYNOPSIS

#include <stdlib.h> int system(const char *string);

DESCRIPTION

The system() function causes string to be given to the shell as input, as if string had been typed as a command at a ter- minal. 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, sys- tem() 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)). RETURN VALUES 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 vfork(2) or the exec function fails, system() returns -1 and sets errno to indicate the error. ERRORS The system() function fails if: EAGAIN The system-imposed limit on the total number of processes under execution by a single user would be exceeded. EINTR The system() function was interrupted by a signal. ENOMEM The new process requires more memory than is avail- able. USAGE The system() function will fail to execute setuid() or set- gid() if either the UID or GID of the application's owner/group is less than 100. See useradd(1M) and setuid(2). The system() function is implemented using vfork(2), which is much less likely to fail due to resource constraints than fork(2). SunOS 5.8 Last change: 12 Oct 1999 1 Standard C Library Functions system(3C)

ATTRIBUTES

See attributes(5) for descriptions of the following attri- butes: ____________________________________________________________ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |_____________________________|_____________________________| | MT-Level | Unsafe | |_____________________________|_____________________________|

SEE ALSO

ksh(1), sh(1), useradd(1M), exec(2), fork(2), setuid(2), vfork(2), waitpid(2), attributes(5), standards(5) SunOS 5.8 Last change: 12 Oct 1999 2