1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified Sat Jul 24 17:51:15 1993 by Rik Faith (faith@cs.unc.edu)
26 .\" Modified 11 May 1998 by Joseph S. Myers (jsm28@cam.ac.uk)
27 .\" Modified 14 May 2001, 23 Sep 2001 by aeb
30 .TH SYSTEM 3 2010-09-10 "" "Linux Programmer's Manual"
32 system \- execute a shell command
35 .B #include <stdlib.h>
37 .BI "int system(const char *" "command" );
41 executes a command specified in
46 and returns after the command has been completed.
47 During execution of the command,
55 The value returned is \-1 on error (e.g.,
58 and the return status of the command otherwise.
59 This latter return status is in the format
62 Thus, the exit code of the command will be
63 .IR WEXITSTATUS(status) .
66 could not be executed, the exit status will be that of
74 returns nonzero if the shell is available, and zero if not.
77 does not affect the wait status of any other children.
79 C89, C99, POSIX.1-2001.
84 feature test macro is defined
88 then the macros described in
91 etc.) are made available when including
100 This may make programs that call it
101 from a loop uninterruptible, unless they take care themselves
102 to check the exit status of the child.
108 int ret = system("foo");
110 if (WIFSIGNALED(ret) &&
111 (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))
118 from a program with set-user-ID or set-group-ID privileges,
119 because strange values for some environment variables
120 might be used to subvert system integrity.
123 family of functions instead, but not
128 will not, in fact, work properly from programs with set-user-ID or
129 set-group-ID privileges on systems on which
131 is bash version 2, since bash 2 drops privileges on startup.
132 (Debian uses a modified bash which does not do this when invoked as
135 In versions of glibc before 2.1.3, the check for the availability of
137 was not actually performed if
139 was NULL; instead it was always assumed to be available, and
141 always returned 1 in this case.
142 Since glibc 2.1.3, this check is performed because, even though
143 POSIX.1-2001 requires a conforming implementation to provide
144 a shell, that shell may not be available or executable if
145 the calling program has previously called
147 (which is not specified by POSIX.1-2001).
149 It is possible for the shell command to return 127, so that code is not
150 a sure indication that the
159 This page is part of release 3.65 of the Linux
162 A description of the project,
163 and information about reporting bugs,
165 \%http://www.kernel.org/doc/man\-pages/.