[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    system(3S) manual page Table of Contents

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) ).


Table of Contents