SYSTEM
Section: Linux Programmer's Manual (3)
Updated: April 13, 1993
Index
Return to Main Contents
NAME
system - execute a shell command
SYNOPSIS
#include <stdlib.h>
int system (const char * string);
DESCRIPTION
system()
executes a command specified in
string
by calling
/bin/sh -c
string,
and returns after the command has been completed.
During execution of the command,
SIGCHLD
will be blocked, and
SIGINT
and
SIGQUIT
will be ignored.
RETURN VALUE
The value returned is 127 if the
execve()
call for
/bin/sh
fails, -1 if there was another error and the return code of the
command otherwise.
If the value of
string
is
NULL,
system()
returns nonzero if the shell is available, and zero if not.
system()
does not affect the wait status of any other children.
CONFORMS TO
ANSI C, POSIX.1, proposed POSIX.2, BSD 4.3
BUGS
Do not use
system()
from a program with suid or sgid privileges, because strange values for
some environment variables might be used to subvert system integrity.
Use the
exec(2)
family of functions instead, but not
execlp(2)
or
execvp(2).
The check for the availability of
/bin/sh
is not actually performed; it is always assumed to be available.
It is possible for the shell command to return 127, so that code is not a sure
indication that the
execve()
call failed; check
errno
to make sure.
SEE ALSO
sh(1), exec(2), signal(2)
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- RETURN VALUE
-
- CONFORMS TO
-
- BUGS
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 12:23:08 GMT, March 22, 2025