OSDN Git Service

11ee01bc46169156b5c7c319110c55b2ba7d7022
[linuxjm/LDP_man-pages.git] / release / man2 / reboot.2
1 .\" Copyright (c) 1998 Andries Brouwer (aeb@cwi.nl), 24 September 1998
2 .\"
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.
6 .\"
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.
11 .\"
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
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
23 .\"     Added notes on capability requirements
24 .\"
25 .\" Japanese Version Copyright (c) 1997 Ueyama Rui
26 .\"         all rights reserved.
27 .\" Translated Mon Sep 29 23:21:04 JST 1997
28 .\"         by Ueyama Rui <rui@campus.ne.jp>
29 .\" Updated & Modified Mon Mar 1 1999
30 .\"         by NAKANO Takeo <nakano@apm.seikei.ac.jp>
31 .\" Updated Sat Oct 11 JST 2003 by Kentaro Shirakata <argrath@ub32.org>
32 .\"
33 .\"WORD         halt            停止
34 .\"WORD         stop            停止
35 .\"WORD         reboot          再起動
36 .\"
37 .TH REBOOT 2 2008-02-11 "Linux" "Linux Programmer's Manual"
38 .SH 名前
39 reboot \- 再起動する。または Ctrl-Alt-Delを有効・無効にする
40 .SH 書式
41 /* libc4 と libc5 でのライブラリコールとシステムコールは同じである。
42    またカーネル 2.1.30 以降では、定数としてシンボリックな名前
43    LINUX_REBOOT_* が定義されており、呼び出しの第 4 引数として
44    指定することができる。*/
45 .sp
46 .B #include <unistd.h>
47 .br
48 .B #include <linux/reboot.h>
49 .sp
50 .BI "int reboot(int " magic ", int " magic2 ", int " cmd ", void *" arg );
51 .sp
52 /* glibc では、関連する定数に RB_* というシンボリックな名前が付け
53    られている。ライブラリ関数の引数は 1 つで、3 引数のシステムコールの
54    ラッパ (wrapper) となっている。 */
55 .sp
56 .B #include <unistd.h>
57 .br
58 .B #include <sys/reboot.h>
59 .sp
60 .BI "int reboot(int " cmd );
61 .SH 説明
62 .BR reboot ()
63 はシステムを再起動する。または再起動のキーストロークである
64 Ctrl-Alt-Delete (CAD) を有効/無効にする。
65 このキーストロークは
66 .BR loadkeys (1)
67 によって変更できる。
68 .PP
69 .I magic
70
71 .B LINUX_REBOOT_MAGIC1
72 (値は 0xfee1dead) であり、かつ
73 .I magic2
74
75 .B LINUX_REBOOT_MAGIC2
76 (672274793) でなければこのシステムコールは失敗し、
77 .B EINVAL
78 が返される。
79 しかし 2.1.17 からは
80 .B LINUX_REBOOT_MAGIC2A
81 (85072278) が、
82 また 2.1.97 からは
83 .B LINUX_REBOOT_MAGIC2B
84 (369367448) が、
85 2.5.71 からは
86 .B LINUX_REBOOT_MAGIC2C
87 (537993216) が
88 .I magic2
89 の値として指定できるようになった (これらの定数の 16 進での
90 表記にはちょっとした意味がある)。
91 .I cmd
92 引数には以下の値を指定できる。
93 .TP
94 .B LINUX_REBOOT_CMD_RESTART
95 (RB_AUTOBOOT, 0x1234567)
96 "Restarting system." というメッセージが表示され、
97 デフォルトの再起動処理がただちに実行される。
98 先に
99 .BR sync (2)
100 を行なわないと、データが失われる。
101 .TP
102 .B LINUX_REBOOT_CMD_HALT
103 (RB_HALT_SYSTEM, 0xcdef0123; 1.1.76 以降)
104 "System halted." というメッセージが表示され、システムは停止 (halt) する。
105 制御は ROM モニタに移る (ROM モニタがある場合)。
106 先に
107 .BR sync (2)
108 を行なわないと、データが失われる。
109 .TP
110 .B LINUX_REBOOT_CMD_POWER_OFF
111 (0x4321fedc; 2.1.30 以降)
112 "Power down" というメッセージが表示され、システムは停止 (stop) する。
113 可能な場合はシステムの電源が落とされる。
114 先に
115 .BR sync (2)
116 を行なわないと、データが失われる。
117 .TP
118 .B LINUX_REBOOT_CMD_RESTART2
119 (0xa1b2c3d4; 2.1.30 以降)
120 "Restarting system with command \(aq%s\(aq" というメッセージが表示され、
121 ただちに (
122 .I arg
123 に指定されたコマンドを用いて) 再起動 (restart) が行われる。
124 先に
125 .BR sync (2)
126 を行なわないと、データが失われる。
127 .TP
128 .B LINUX_REBOOT_CMD_CAD_ON
129 (RB_ENABLE_CAD, 0x89abcdef)
130 CAD を有効にする。
131 これ以降に CAD キーストロークが入力されると、
132 ただちに
133 .B LINUX_REBOOT_CMD_RESTART
134 に関連付けられた動作が行われるようになる。
135 .TP
136 .B LINUX_REBOOT_CMD_CAD_OFF
137 (RB_DISABLE_CAD, 0)
138 CAD を無効にする。
139 これ以降に CAD キーストロークが入力されると、
140 .B SIGINT
141 シグナルが init (プロセス 1) に送られる。
142 このシグナルを受けると、おそらく init プロセスは
143 前もって定められた動作を行うことになる (多分すべてのプロセスの kill,
144 sync, 再起動)。
145 .LP
146 スーパーユーザーだけが
147 .BR reboot ()
148 を呼び出すことができる。
149 .LP
150 上述のアクションの実際の効果はアーキテクチャに依存する。
151 i386 アーキテクチャでは、現在のところ (2.1.122) 付加引数は
152 何も行わないが、再起動のタイプをカーネルのコマンドライン引数
153 ("reboot=...") によって定めることができる。
154 これには warm または cold と、 hard または BIOS 経由の再起動を
155 設定できる。
156 .SH 返り値
157 .I cmd
158 がシステムの停止や再起動を表す値の場合、呼び出しが成功すると
159 .BR reboot ()
160 は返らない。
161 .I cmd
162 が他の値の場合には、成功すると 0 が返る。
163 .I cmd
164 の値に関わらず、失敗の場合には \-1 が返り、
165 .I errno
166 が適切に設定される。
167 .SH エラー
168 .TP
169 .B EFAULT
170 .B LINUX_REBOOT_CMD_RESTART2
171 の時にユーザースペースのデータの取得に問題があった。
172 .TP
173 .B EINVAL
174 magic の数字か \fIcmd\fP が間違っている。
175 .TP
176 .B EPERM
177 呼び出し元プロセスに
178 .BR reboot ()
179 を呼び出すのに十分な権限がなかった。
180 .B CAP_SYS_BOOT
181 ケーパビリティが必要である。
182 .SH 準拠
183 .BR reboot ()
184 は Linux に特有であり、移植を考慮したプログラムでは用いるべきではない。
185 .SH 関連項目
186 .BR sync (2),
187 .BR bootparam (7),
188 .BR ctrlaltdel (8),
189 .BR halt (8),
190 .BR reboot (8),
191 .BR capabilities (7)