system
Purpose
Runs a shell command.
Library
Standard C Library (libc.a)
Syntax
#include <stdio.h>
int system (string)
char *string;
Description
The system subroutine passes the string parameter to the
sh command as input. Then sh interprets string as a
command and runs it.
The system subroutine invokes the fork system call to
create a child process that in turn uses exec to run
/bin/sh, which interprets the shell command contained in
the string parameter. The current process waits until
the shell has completed, then returns the exit status of
the shell.
Note: The system subroutine runs only sh shell commands
(also called Bourne shell commands). The results are
unpredictable if the string parameter is not a valid sh
shell command.
Return Value
Upon successful completion, the system subroutine returns
the exit status of the shell. See "wait" for an explana-
tion of the exit status.
If the fork fails, then system returns a value of -1. If
the exec fails, then it returns 127. It either case,
errno is set to indicate the error.
File
/bin/sh
Related Information
In this book: "exec: execl, execv, execle, execve,
execlp, execvp," "exit, _exit," "fork," and "wait."
The sh command in AIX Operating System Commands
Reference.