SYSTEM(3S) COMMAND REFERENCE SYSTEM(3S)
NAME
system - issue a shell command
SYNOPSIS
system(string)
char *string;
DESCRIPTION
System causes the string to be given to sh(1sh) as input as
if the string had been typed as a command at a terminal.
The current process waits until the shell has completed,
then returns the exit status of the shell.
DIAGNOSTICS
Exit status 127 indicates the shell couldn't be executed.
CAVEATS
It is very important to remember that system executes sh.
This means that shell metacharacters such as `*' and `|' are
interpreted, even when present in filenames. This can cause
undesirable results when system is used to execute commands
with arguments provided by the user.
Since system executes sh, the overhead of executing sh, such
as copying the environment into shell variables, causes
system to be slower than simply using fork and exec.
For these reasons, it is best to use system in cases where
the command to be executed contains shell variables and/or
redirection and/or pipes, which are difficult to build in to
a program.
SEE ALSO
execve(2), fork(2), wait(2), and popen(3s).
Printed 3/13/89 1
%%index%%
na:312,82;
sy:394,389;
de:783,490;
di:1273,186;
ca:1459,1248;
se:2707,194;
%%index%%000000000108