8999 SMBIOS: cleanup 32-bit specific code
[unleashed.git] / usr / src / man / man3c / system.3c
bloba97eb5795e76514c3c27fdfd00dc79a018a6badc
1 '\" te
2 .\" Copyright (c) 2006, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
6 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
8 .\"  This notice shall appear on any product containing this material.
9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
12 .TH SYSTEM 3C "Dec 14, 2006"
13 .SH NAME
14 system \- issue a shell command
15 .SH SYNOPSIS
16 .LP
17 .nf
18 #include <stdlib.h>
20 \fBint\fR \fBsystem\fR(\fBconst char *\fR\fIstring\fR);
21 .fi
23 .SH DESCRIPTION
24 .sp
25 .LP
26 The \fBsystem()\fR function causes \fIstring\fR to be given to the shell as
27 input, as if \fIstring\fR had been typed as a command at a terminal. The
28 invoker waits until the shell has completed, then returns the exit status of
29 the shell in the format specified by \fBwaitpid\fR(3C).
30 .sp
31 .LP
32 If \fIstring\fR is a null pointer, \fBsystem()\fR checks if the shell exists
33 and is executable.  If the shell is available, \fBsystem()\fR returns a
34 non-zero value; otherwise, it returns \fB0\fR.
35 .sp
36 .LP
37 The \fBsystem()\fR function sets the \fBSIGINT\fR and \fBSIGQUIT\fR signals to
38 be ignored, and blocks the \fBSIGCHLD\fR signal for the calling thread, while
39 waiting for the command to terminate. The \fBsystem()\fR function does not
40 affect the termination status of any child of the calling processes other than
41 the process it creates.
42 .sp
43 .LP
44 The termination status of the process created by the \fBsystem()\fR function is
45 not affected by the actions of other threads in the calling process (it is
46 invisible to \fBwait\fR(3C)) or by the disposition of the \fBSIGCHLD\fR signal
47 in the calling process, even if it is set to be ignored. No \fBSIGCHLD\fR
48 signal is sent to the process containing the calling thread when the command
49 terminates.
50 .SH RETURN VALUES
51 .sp
52 .LP
53 The \fBsystem()\fR function executes \fBposix_spawn\fR(3C) to create a child
54 process running the shell that in turn executes the commands in \fIstring\fR.
55 If \fBposix_spawn()\fR fails, \fBsystem()\fR returns \fB\(mi1\fR and sets
56 \fBerrno\fR to indicate the error; otherwise the exit status of the shell is
57 returned.
58 .SH ERRORS
59 .sp
60 .LP
61 The \fBsystem()\fR function may set \fBerrno\fR values as described by
62 \fBfork\fR(2), in particular:
63 .sp
64 .ne 2
65 .na
66 \fB\fBEAGAIN\fR\fR
67 .ad
68 .RS 10n
69 A resource control or  limit on the total number of  processes, tasks or LWPs
70 under execution by a single user,  task,  project, or  zone has been exceeded,
71 or the total amount of system memory available  is temporarily insufficient to
72 duplicate this process.
73 .RE
75 .sp
76 .ne 2
77 .na
78 \fB\fBENOMEM\fR\fR
79 .ad
80 .RS 10n
81 There is not enough swap space.
82 .RE
84 .sp
85 .ne 2
86 .na
87 \fB\fBEPERM\fR\fR
88 .ad
89 .RS 10n
90 The  {\fBPRIV_PROC_FORK\fR} privilege is  not asserted in the effective set of
91 the calling process.
92 .RE
94 .SH USAGE
95 .sp
96 .LP
97 The \fBsystem()\fR function manipulates the signal handlers for \fBSIGINT\fR
98 and \fBSIGQUIT\fR. It is therefore not safe to call \fBsystem()\fR in a
99 multithreaded process, since some other thread that manipulates these signal
100 handlers and a thread that concurrently calls \fBsystem()\fR can interfere with
101 each other in a destructive manner.  If, however, no such other thread is
102 active, \fBsystem()\fR can safely be called concurrently from multiple threads.
103 See \fBpopen\fR(3C) for an alternative to \fBsystem()\fR that is thread-safe.
104 .SH ATTRIBUTES
107 See \fBattributes\fR(5) for descriptions of the following attributes:
112 box;
113 c | c
114 l | l .
115 ATTRIBUTE TYPE  ATTRIBUTE VALUE
117 Interface Stability     Standard
119 MT-Level        Unsafe
122 .SH SEE ALSO
125 \fBksh\fR(1), \fBsh\fR(1), \fBpopen\fR(3C), \fBposix_spawn\fR(3C),
126 \fBwait\fR(3C), \fBwaitpid\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)