Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

system(3) [netbsd man page]

SYSTEM(3)						   BSD Library Functions Manual 						 SYSTEM(3)

NAME
system -- pass a command to the shell LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdlib.h> int system(const char *string); DESCRIPTION
The system() function hands the argument string to the command interpreter sh(1). The calling process waits for the shell to finish execut- ing the command, ignoring SIGINT and SIGQUIT, and blocking SIGCHLD. If string is a NULL pointer, system() will return non-zero, if the command interpreter is available, or zero if none is available. Other- wise, system() returns the termination status of the shell in the format specified by waitpid(2). RETURN VALUES
If a child process cannot be created, or the termination status of the shell cannot be obtained, system() returns -1 and sets errno to indi- cate the error. If execution of the shell fails, system() returns the termination status for a program that terminates with a call of exit(127). SEE ALSO
sh(1), execve(2), waitpid(2), popen(3), shquote(3) STANDARDS
The system() function conforms to ANSI X3.159-1989 (``ANSI C89'') and IEEE Std 1003.2-1992 (``POSIX.2''). CAVEATS
Never supply the system() function with a command containing any part of an unsanitized user-supplied string. Shell meta-characters present will be honored by the sh(1) command interpreter. BSD
August 2, 2007 BSD

Check Out this Related 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)
Man Page