NAME
system - Executes a shell command
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <stdlib.h>
int system (
const char *command );
PARAMETERS
command Specifies a valid sh shell command.
DESCRIPTION
The system() function passes the command parameter to the sh
command, which interprets command as a command and executes
it.
The system() function invokes the fork() function to create
a child process that in turn uses the exec function to run
sh, which interprets the shell command contained in the com-
mand parameter. The current process waits until the shell
has completed, then returns the exit status of the shell.
Note that the system() function affects only the process(es)
that it created.
Beware that while waiting for command to finish executing,
the system() function ignores the SIGINT and SIGQUIT sig-
nals, and blocks SIGCHLD. If this characteristic causes
your application to miss a signal that might have terminated
the application, you should have the application check the
system() function's return value and then perform the opera-
tion that would have been executed if the application had
caught that signal.
NOTES
AES Support Level:
Full use
RETURN VALUES
The system() function does not return until its child pro-
cess has terminated.
If the argument specified by the command parameter is a null
pointer, the system() function returns 1 only if a command
processor is available.
If the argument is not a null pointer, upon successful
completion, the system() function returns the exit status of
the executed command in the format specified by the wait-
pid() function (see the wait(2) function). If the function
fails, such as when the child process cannot be created or
if the shell's exit status cannot be obtained, the system()
function returns a value of -1 and sets errno to indicate
the error. A return value of 127 indicates that the shell
could not be executed.
ERRORS
If the system() function fails, errno may be set to one of
the following values:
[EAGAIN] The system-imposed limit on the total number of
processes under execution system-wide
({PROC_MAX}), or by a single user ID
({CHILD_MAX}), would be exceeded.
[EINTR] The system() function was interrupted by a signal
which was caught.
[ENOMEM] There is not enough space left for this process.
RELATED INFORMATION
Functions: exec(2), exit(2), fork(2), wait(2)
Commands: sh(1)
Acknowledgement and Disclaimer