Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ system(3S) — SunOS 5.6

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ksh(1)

sh(1)

useradd(1M)

exec(2)

fork(2)

setuid(2)

waitpid(2)

attributes(5)

standards(5)

system(3S)

NAME

system − issue a shell command

SYNOPSIS

#include <stdlib.h>

int system(const char ∗string);

DESCRIPTION

The system() function causes the string to be given to the shell as input, as if the string had been typed as a command at a terminal.  The invoker waits until the shell has completed, then returns the exit status of the shell in the format specified by waitpid(2). 

If string is a null pointer, system() checks if the shell exists and is executable.  If the shell is available, system() returns non-zero; otherwise it returns zero.  If the application is standard-conforming (see standards(5)), system() uses /usr/bin/ksh (see ksh(1)); otherwise system() uses /usr/bin/sh (see sh(1)). 

RETURN VALUES

The system() function forks to create a child process that in turn execs the shell in order to execute string. If the fork() or exec() fails, system() returns a value of −1 and sets errno. 

ERRORS

The system() function 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. 

EINTR system() was interrupted by a signal. 

ENOMEM The new process requires more memory than is available. 

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
MT-Level Unsafe

SEE ALSO

ksh(1), sh(1), useradd(1M), exec(2), fork(2), setuid(2), waitpid(2), attributes(5), standards(5)

NOTES

The system() function will fail to execute setuid() or setgid() if either the uid or gid of the application’s owner/group is less than 100.  (see useradd(1M) and setuid(2)). 

SunOS 5.6  —  Last change: 26 Feb 1997

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026