'\"macro stdmacro
.if n .pH g3s.system @(#)system	40.12 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} system 3S "C Programming Language Utilities" "\&"
.if \nX=1 .ds x} system 3S "C Programming Language Utilities"
.if \nX=2 .ds x} system 3S "" "\&"
.if \nX=3 .ds x} system "" "" "\&"
.TH \*(x}
.SH NAME
\f4system\f1 \- issue a shell command 
.SH SYNOPSIS
\f4#include <stdlib.h>\f1
.PP
\f4int system (const char \(**string);\f1
.SH DESCRIPTION
\f4system\fP
causes the
.I string\^
to be given to the shell
[see \f4sh\fP(1)]
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
in the format specified by \f4waitpid\fP.
.PP
If \f2string\f1 is a \f4NULL\fP pointer, \f4system\fP checks if \f4/sbin/sh\fP
exists and is executable.  If \f4/sbin/sh\fP is available, \f4system\fP
returns non-zero; otherwise it returns zero.
.PP
\f4system\fP fails if one or more of the following are true:
.TP 12
\f4EAGAIN\fP
The system-imposed limit on the total number of processes under execution by
a single user would be exceeded.
.TP 12
\f4EINTR\fP
\f4system\fP was interupted by a signal.
.TP 12
\f4ENOMEM\fP
The new process requires more memory than is allowed by the system-imposed
maximum \f4MAXMEM\fP.
.SH "SEE ALSO"
\f4exec\fP(2),
\f4waitpid\fP(3C).
.br
\f4sh\fP(1) in the
\f2User's Reference Manual\f1.
.SH DIAGNOSTICS
\f4system\fP
forks to create a child process
that in turn execs
\f4/sbin/sh\fP
in order to execute
.IR string .
If the fork or exec fails,
\f4system\fP
returns a value of -1 and sets
\f4errno\fP.
.\"	@(#)system.3s	6.3 of 10/20/83
.Ee
