system(S)
system --
issue a shell command
Syntax
cc . . . -lc
#include <stdio.h>
#include <stdlib.h>
int system (string)
char *string;
Description
The system function causes the
string to be given to
sh(C)
as input, as if the string had been typed as a command
at a terminal.
The current process waits until the shell has
completed.
Files
/bin/sh
Return value
If string is not a null pointer,
system
returns the exit status of the shell in the same format
as specified by the
waitpid(S)
function.
The meaning of the return value,
if it is not -1,
can be decoded
via macros like WIFEXITED
defined in <sys/wait.h>, as described in
waitpid(S).
Diagnostics
The system function
forks to create a child process
that in turn executes (using
exec(S))
/bin/sh in order to execute
string.
If the fork fails, system
returns -1 and sets errno.
If the fork succeeds but exec fails, system
returns a value as if
sh(C)
had terminated using
_exit(127).
The system function fails if:
[EAGAIN]-
The system-imposed limit on the total number of processes under
execution, system-wide, or by a single user ID
(CHILD_MAX), would be exceeded.
[ENOMEM]-
Insufficient storage space is available.
See also
_exit(S),
exec(S),
sh(C)
Standards conformance
system is conformant with:
X/Open Portability Guide, Issue 3, 1989
;
and
ANSI X3.159-1989 Programming Language -- C
.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003