system(3S)


system -- issue a shell command

Synopsis

   #include <stdlib.h>
   

int system(const char *string);

Description

system causes the string to be given to a command shell as input, as if it had been typed as a command at a terminal. system forks to create a child process that runs the command shell specified in the SHELL environment variable in the current environment; this shell executes string. If SHELL is not set, then /bin/sh is used.

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 the shell specified in the SHELL environment variable exists and is executable. If it 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.

References

exec(2), sh(1), ksh(1), ksh88(1), wstat(5)

Compatibility

Previous versions of UnixWare and SCO OpenServer always used /bin/sh as the shell in which command is executed. Applications built for previous system versions may require that SHELL be set to /bin/sh in the caller's environment.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004