1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Modified Sat Jul 24 17:51:15 1993 by Rik Faith (faith@cs.unc.edu)
24 .\" Modified 11 May 1998 by Joseph S. Myers (jsm28@cam.ac.uk)
25 .\" Modified 14 May 2001, 23 Sep 2001 by aeb
28 .\" Japanese Version Copyright (c) 1996 Shoichi OZAWA
29 .\" all right reserved.
30 .\" Translated 1996-09-01, Shoichi OZAWA <ozawa@omika.hitachi.co.jp>
31 .\" Updated 2001-03-19, Kentaro Shirakata <argrath@ub32.org>
32 .\" Updated 2001-10-16, Kentaro Shirakata <argrath@ub32.org>
33 .\" Updated 2005-02-27, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
35 .\"WORD: feature test macro µ¡Ç½¸¡ºº¥Þ¥¯¥í
37 .TH SYSTEM 3 2004-12-20 "" "Linux Programmer's Manual"
39 system \- ¥·¥§¥ë¥³¥Þ¥ó¥É¤Î¼Â¹Ô
42 .B #include <stdlib.h>
44 .BI "int system(const char *" "command" );
53 ¤Î·Á¤Ç¼Â¹Ô¤¹¤ë¡£»ØÄꤷ¤¿¥³¥Þ¥ó¥É¤¬½ªÎ»¤¹¤ì¤Ð¤³¤Î´Ø¿ô¤â½ªÎ»¤¹¤ë¡£
64 ¤Ë¼ºÇÔ¤·¤¿¾ì¹ç¤Ê¤É)¡¢\-1 ¤òÊÖ¤¹¡£
65 ¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¡¢¥³¥Þ¥ó¥É¤Î¥¹¥Æ¡¼¥¿¥¹¤òÊÖ¤¹¡£
66 ¸å¼Ô¤Î¾ì¹ç¡¢¥¹¥Æ¡¼¥¿¥¹¤Ï
68 ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥Õ¥©¡¼¥Þ¥Ã¥È¤ÇÊ֤äƤ¯¤ë¡£
69 ½¾¤Ã¤Æ¡¢¥³¥Þ¥ó¥É¤Î½ªÎ»¥³¡¼¥É¤Ï
70 .I WEXITSTATUS(status)
73 ¤¬¼Â¹Ô½ÐÍè¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
74 ½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤Ï¥³¥Þ¥ó¥É¤¬
76 ¤ò¼Â¹Ô¤·¤¿¾ì¹ç¤ÈƱ¤¸¤Ë¤Ê¤ë¡£
79 ¤ÎÃͤ¬ NULL ¤Î¤È¤¤Ï¡¢
81 ¤Ï¥·¥§¥ë¤¬ÍøÍѲÄǽ¤Ê¤é¥¼¥í°Ê³°¤ÎÃͤòÊÖ¤·¡¢ÍøÍÑÉԲĤʤ饼¥í¤òÊÖ¤¹¡£
84 ¤Ï¾¤Î»Ò¥×¥í¥»¥¹¤Î¥¦¥¨¥¤¥È¥¹¥Æ¡¼¥¿¥¹¤Ë¤Ï±Æ¶Á¤òÍ¿¤¨¤Ê¤¤¡£
86 C89, C99, POSIX.1-2001.
91 ¤¬ÄêµÁ¤µ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
93 ¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë¥Þ¥¯¥í·²
97 ¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë¤ÈÍøÍѲÄǽ¤Ë¤Ê¤ë¡£
109 °Ê²¼¤ÎÎã¤Î¤è¤¦¤Ë»Ò¥×¥í¥»¥¹¤Î½ªÎ»¾õÂÖ¤ò¼«Ê¬¤Ç¥Á¥§¥Ã¥¯¤·¤Æ¤ª¤«¤Ê¤¤¤È¡¢
110 ÃæÃǤǤ¤Ê¤¯¤Ê¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
115 int ret = system("foo");
117 if (WIFSIGNALED(ret) &&
118 (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))
123 set-user-ID ¤ä set-group-ID ¤ÎÆø¢¤ò¤â¤Ä¥×¥í¥°¥é¥à¤ÎÃæ¤Ç¤Ï
125 ¤ò»È¤Ã¤Æ¤Ï¤¤¤±¤Ê¤¤¡£¤Ê¤¼¤Ê¤é¡¢¤¢¤ë´Ä¶ÊÑ¿ô¤Î̤ÃΤÎÃͤˤè¤Ã¤Æ
126 ¥·¥¹¥Æ¥à¤Î°ÂÁ´¤¬Â»¤Ê¤ï¤ì¤ë¤«¤é¤Ç¤¢¤ë¡£Âå¤ï¤ê¤Ë
132 °Ê³°¤Î´Ø¿ô¤ò»ÈÍѤ¹¤Ù¤¤Ç¤¢¤ë¡£
137 ¤¬ bash ¥Ð¡¼¥¸¥ç¥ó 2 ¤Ç¤¢¤ë¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
138 set-user-ID ¤ä set-group-ID ¤ÎÆø¢¤ò»ý¤Ä¥×¥í¥°¥é¥à¤«¤é¤ÏÀµ¤·¤¯Æ°ºî¤·¤Ê¤¤¡£
139 ¤Ê¤¼¤Ê¤é¡¢bash ¥Ð¡¼¥¸¥ç¥ó 2 ¤Ï¥¹¥¿¡¼¥È¥¢¥Ã¥×»þ¤ËÆø¢¤òÍî¤È¤¹¤«¤é¤Ç¤¢¤ë¡£
140 (Debian ¤Ç¤Ï¡¢sh ¤È¤·¤Æµ¯Æ°¤µ¤ì¤¿»þ¤Ë¤Ï¤³¤Î¤è¤¦¤ÊÆ°ºî¤ò¹Ô¤Ê¤ï¤Ê¤¤¤è¤¦¤Ë
141 ½¤Àµ¤µ¤ì¤¿ bash ¤òÍѤ¤¤Æ¤¤¤ë)
143 glibc 2.1.3 ¤è¤êÁ°¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï¡¢
147 ¤¬ÍøÍѲÄǽ¤«¤É¤¦¤«¤Î¥Á¥§¥Ã¥¯¤Ï¼ÂºÝ¤Ë¤Ï¹Ô¤ï¤º¡¢
148 ¤¤¤Ä¤Ç¤âÍøÍѲÄǽ¤Ç¤¢¤ë¤È¤ß¤Ê¤·¤Æ¤¤¤¿¡£
150 ¤Ï¤³¤Î¾ì¹ç¤Ë¾ï¤Ë 1 ¤òÊÖ¤·¤Æ¤¤¤¿¡£
151 POSIX.1-2001 ¤Ç¤Ï¥·¥§¥ë¤¬Ä󶡤µ¤ì¤Æ¤¤¤ë¤È¤¤¤¦É¸½à¤Ë½àµò¤·¤¿¼ÂÁõ¤ò
152 Í׵ᤷ¤Æ¤¤¤ë¤¬¡¢glibc 2.1.3 °Ê¹ß¤Ç¤Ï¥·¥§¥ë¤Î¥Á¥§¥Ã¥¯¤ò¼Â¹Ô¤·¤Æ¤¤¤ë¡£
153 ¤Ê¤¼¤Ê¤é¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥°¥é¥à¤¬
155 ¤ò¸Æ¤Ó½Ð¤¹¤è¤êÁ°¤Ë (POSIX.1-2001 ¤Ç¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤)
157 ¤ò¸Æ¤Ó½Ð¤·¤Æ¤¤¤¿»þ¤Ë¤Ï¡¢¥·¥§¥ë¤¬ÍøÍѲÄǽ¤Ç¤Ê¤¤¾ì¹ç¤ä¼Â¹Ô²Äǽ¥Õ¥¡¥¤¥ë
158 ¤Ç¤Ê¤¤¾ì¹ç¤¬¤¢¤ë¤«¤é¤Ç¤¢¤ë¡£
160 ¼Â¹Ô¤·¤¿¥·¥§¥ë¥³¥Þ¥ó¥É¤¬ 127
162 ¤Î¸Æ¤Ó½Ð¤·¤Ë¼ºÇÔ¤·¤¿»þ¤ËÊÖ¤¹ÃÍ) ¤òÊÖ¤¹¤³¤È¤â¹Í¤¨¤é¤ì¤ë¡£
163 ¤½¤Î¤¿¤á¡¢¥×¥í¥°¥é¥à¤Ï (¥ê¥¿¡¼¥ó¥³¡¼¥É¤ò¸«¤ë¤À¤±¤Ç¤Ï)
165 ¤Î¸Æ¤Ó½Ð¤·¤¬¼ºÇÔ¤·¤¿¤³¤È¤ò³Î¼Â¤ËÃΤ뤳¤È¤Ï¤Ç¤¤Ê¤¤¡£