.\" (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de) .\" This file can be distributed under the terms of the GNU General Public .\" License. .\" Modified Sat Jul 24 17:51:15 1993 by Rik Faith (faith@cs.unc.edu) .TH SYSTEM 3 "April 13, 1993" "GNU" "Linux Programmer's Manual" .SH NAME system \- execute a shell command .SH SYNOPSIS .nf .B #include .sp .BI "int system (const char * " "string" ");" .fi .SH DESCRIPTION .B system() executes a command specified in .I string by calling .BR "/bin/sh -c" .IR string , and returns after the command has been completed. During execution of the command, .B SIGCHLD will be blocked, and .B SIGINT and .B SIGQUIT will be ignored. .SH "RETURN VALUE" The value returned is 127 if the .B execve() call for .B /bin/sh fails, \-1 if there was another error and the return code of the command otherwise. .PP If the value of .I string is .BR NULL , .B system() returns nonzero if the shell is available, and zero if not. .PP .B system() does not affect the wait status of any other children. .SH "CONFORMS TO" ANSI C, POSIX.1, proposed POSIX.2, BSD 4.3 .SH "BUGS" .PP Do not use .B system() from a program with suid or sgid privileges, because strange values for some environment variables might be used to subvert system ingetrity. Use the .BR exec (2) family of functions instead, but not .BR execlp (2) or .BR execvp (2). .PP The check for the availability of .B /bin/sh is not actually performed; it is always assumed to be available. .PP It is possible for the shell command to return 127, so that code is not a sure indication that the .B execve() call failed; check .I errno to make sure. .SH SEE ALSO .BR sh "(1), " exec "(2), " signal (2)