Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

system(3c) [sunos man page]

system(3C)																system(3C)

NAME
system - issue a shell command SYNOPSIS
#include <stdlib.h> int system(const char *string); The system() function causes string to be given to the shell as input, as if 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(3C). If string is a null pointer, system() checks if the shell exists and is executable. If the shell is available, system() returns a non-zero value; otherwise, it returns 0. The standard to which the caller conforms determines which shell is used. See standards(5). The system() function executes vfork(2) to create a child process that in turn invokes one of the exec family of functions (see exec(2)) on the shell to execute string. If vfork() or the exec function fails, system() returns -1 and sets errno to indicate the error. The system() function fails if: EAGAIN The system-imposed limit on the total number of processes under execution by a single user would be exceeded. EINTR The system() function was interrupted by a signal. ENOMEM The new process requires more memory than is available. USAGE
The system() function manipulates the signal handlers for SIGINT, SIGQUIT, and SIGCHLD. It is therefore not safe to call system() in a mul- tithreaded process, since some other thread that manipulates these signal handlers and a thread that concurrently calls system() can inter- fere with each other in a destructive manner. If, however, no such other thread is active, system() can safely be called concurrently from multiple threads. See popen(3C) for an alternative to system() that is thread-safe. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ ksh(1), sh(1), exec(2), vfork(2), popen(3C), waitpid(3C), attributes(5), standards(5) 18 Dec 2003 system(3C)

Check Out this Related Man Page

system(3)						     Library Functions Manual							 system(3)

NAME
system - Executes a shell command LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <stdlib.h> int system( const char *string); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: system(): XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies a valid sh shell command. If string is NULL (0), the system() function tests the accessibility of the sh command interpreter. If string is not NULL, the system() function passes the parameter to the sh command, which interprets string as a command and exe- cutes it. DESCRIPTION
The system() function passes the string parameter to the sh command, which interprets string as a command and executes it. The system() function invokes the fork() function to create a child process that in turn uses the exec function to run sh, which interprets the shell command contained in the string parameter. The current process waits until the shell has completed before returning. RETURN VALUES
If the string parameter is NULL, the system() function returns 0 if it is unable to access the command interpreter or a non-zero value if sh is accessible. If the string parameter is not NULL, upon successful completion by sh, the system() function returns the exit status of the shell process in the form that wait(2) returns. Otherwise, the system() function returns a value of -1 and sets errno to indicate the error. Exit status 127 indicates that the shell could not be executed. Note that the exit status should only be interpreted using the macros described in wait(2) and defined in the sys/wait.h header file. ERRORS
The system() function sets errno to the specified values for the following conditions: The status of the child process created by system() is no longer available. In addition, the system() function may set errno values as described by fork(). RELATED INFORMATION
Functions: exec(2), exit(2), fork(2), wait(2) Commands: sh(1) Standards: standards(5) delim off system(3)
Man Page