File: system.3

package info (click to toggle)
manpages-ja 0.5.0.0.20080615-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 20,508 kB
  • ctags: 1
  • sloc: sh: 13,690; perl: 157; makefile: 114
file content (170 lines) | stat: -rw-r--r-- 4,829 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
.\" (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\" License.
.\" Modified Sat Jul 24 17:51:15 1993 by Rik Faith (faith@cs.unc.edu)
.\" Modified 11 May 1998 by Joseph S. Myers (jsm28@cam.ac.uk)
.\" Modified 14 May 2001, 23 Sep 2001 by aeb
.\" 2004-12-20, mtk
.\"
.\" Japanese Version Copyright (c) 1996 Shoichi OZAWA
.\"	all right reserved.
.\" Translated 1996-09-01, Shoichi OZAWA <ozawa@omika.hitachi.co.jp>
.\" Updated 2001-03-19, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2001-10-16, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2005-02-27, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\"
.\"WORD:	feature test macro	ǽޥ
.\"
.TH SYSTEM 3  2004-12-20 "" "Linux Programmer's Manual"
.SH ̾
system \- 륳ޥɤμ¹
.SH 
.nf
.B #include <stdlib.h>
.sp
.BI "int system(const char *" "command" );
.fi
.SH 
.BR system ()

.I command
ǻꤷޥɤ
.B "/bin/sh \-c"
.I command
ηǼ¹Ԥ롣ꤷޥɤλФδؿ⽪λ롣
ޥɼ¹ϡ
.B SIGCHLD
ϥ֥å졢
.B SIGINT

.B SIGQUIT
̵뤵롣
.SH ֤
顼ȯ
.RB ( fork (2)
˼Ԥʤ)\-1 ֤
ǤʤСޥɤΥơ֤
Ԥξ硢ơ
.BR wait (2)
ƤեޥåȤ֤äƤ롣
äơޥɤνλɤ
.I WEXITSTATUS(status)
뤳Ȥ롣
.I /bin/sh
¹Խʤä硢
λơϥޥɤ
.I exit(127)
¹ԤƱˤʤ롣
.PP
.I command
ͤ NULL ΤȤϡ
.BR system ()
ϥ뤬Ѳǽʤ饼ʳ֤ͤԲĤʤ饼֤
.PP
.BR system ()
¾λҥץΥȥơˤϱƶͿʤ
.SH 
C89, C99, POSIX.1-2001.
.SH 
.PP
ǽޥǤ
.B _XOPEN_SOURCE
줿ˤϡ
.BR wait (2)
Ƥޥ
.RB ( WEXITSTATUS ()
) 
.I <stdlib.h>
򥤥󥯥롼ɤѲǽˤʤ롣
.PP
˽Ҥ٤褦ˡ
.BR system ()

.B SIGINT

.B SIGQUIT
̵뤹롣
äƥ롼פ
.BR system ()
Ƥ֥ץϡ
ʲΤ褦˻ҥץνλ֤ʬǥåƤʤȡ
ǤǤʤʤ뤫⤷ʤ
.br
.nf

    while (something) {
        int ret = system("foo");

        if (WIFSIGNALED(ret) &&
            (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))
                break;
    }
.fi
.PP
set-user-ID  set-group-ID øĥץǤ
.BR system ()
ȤäƤϤʤʤʤ顢Ķѿ̤Τͤˤä
ƥΰ»ʤ뤫Ǥ롣
.BR exec (3)
Ϣδؿ
.BR execlp (3)

.BR execvp (3)
ʳδؿѤ٤Ǥ롣
ºݤΤȤ
.BR system ()

.I /bin/sh
 bash С 2 Ǥ륷ƥǤϡ
set-user-ID  set-group-ID øĥץफưʤ
ʤʤ顢bash С 2 ϥȥå׻øȤǤ롣
(Debian Ǥϡsh ȤƵư줿ˤϤΤ褦ưԤʤʤ褦
줿 bash ѤƤ)
.PP
glibc 2.1.3 ΥСǤϡ
.I command
 NULL ξ
.I /bin/sh
ѲǽɤΥåϼºݤˤϹԤ鷺
ĤǤѲǽǤȤߤʤƤ
.BR system ()
Ϥξ˾ 1 ֤Ƥ
POSIX.1-2001 Ǥϥ뤬󶡤ƤȤɸ˽򤷤
׵ᤷƤ뤬glibc 2.1.3 ʹߤǤϥΥå¹ԤƤ롣
ʤʤ顢ƤӽФΥץब
.BR system ()
ƤӽФ (POSIX.1-2001 ǤϵꤵƤʤ)
.BR chroot (2)
ƤӽФƤˤϡ뤬ѲǽǤʤ¹Բǽե
Ǥʤ礬뤫Ǥ롣
.PP
¹Ԥ륳ޥɤ 127
.RB ( /bin/sh
θƤӽФ˼Ԥ֤) ֤Ȥͤ롣
Τᡢץ (꥿󥳡ɤ򸫤Ǥ)
.BR execve (2)
θƤӽФԤȤμ¤Τ뤳ȤϤǤʤ
.SH Ϣ
.BR sh (1),
.BR signal (2),
.BR wait (2),
.BR exec (3)