system(3S) SDK R4.11 system(3S)
NAME
system - issue a shell command
SYNOPSIS
#include <stdlib.h>
int system(const char *string);
DESCRIPTION
system causes the string to be given to the shell [see sh(1)] as
input, as if it had been typed as a command at a terminal. system
forks to create a child process that in turn execs /sbin/sh in order
to execute string. The current process waits until the shell has
completed, then returns the exit status of the shell. See wstat(5)
for a description of the information packed into the exit status.
Return Values
If string is a NULL pointer, system checks if /sbin/sh exists and is
executable. If /sbin/sh is available, system returns non zero;
otherwise it returns zero. If the fork or exec of string fails,
system returns -1 and sets errno. If the command interpreter cannot
be executed then it behaves as if exit(127) or exit(127) had been
called.
Errors
system fails if one or more of the following are true:
EAGAIN The system-imposed limit on the total number of processes
under execution by a single user would be exceeded.
ENOMEM The new process requires more memory than is allowed by
the system-imposed maximum MAXMEM.
EINTR The parent process was interrupted on the waitpid call
waiting for the child. This errno is only valid when the
libxpg4 (-lxpg4) is not linked into an executable. If
libxpg4 is linked in, system will loop on any waitpid
calls that fail with setting EINTR.
Considerations for Threads Programming
+---------+-----------------------------+
| | async- |
|function | reentrant cancel cancel |
| | point safe |
+---------+-----------------------------+
|system | N - - |
+---------+-----------------------------+
REFERENCES
sh(1), exec(2), reentrant(3), wstat(5)
Licensed material--property of copyright holder(s)