1REBOOT(2) Linux Programmer's Manual REBOOT(2)
2
3
4
6 reboot - reboot or enable/disable Ctrl-Alt-Del
7
9 /* For libc4 and libc5 the library call and the system call
10 are identical, and since kernel version 2.1.30 there are
11 symbolic names LINUX_REBOOT_* for the constants and a
12 fourth argument to the call: */
13
14 #include <unistd.h>
15 #include <linux/reboot.h>
16
17 int reboot(int magic, int magic2, int cmd, void *arg);
18
19 /* Under glibc some of the constants involved have gotten
20 symbolic names RB_*, and the library call is a 1-argument
21 wrapper around the 3-argument system call: */
22
23 #include <unistd.h>
24 #include <sys/reboot.h>
25
26 int reboot(int cmd);
27
29 The reboot() call reboots the system, or enables/disables the reboot
30 keystroke (abbreviated CAD, since the default is Ctrl-Alt-Delete; it
31 can be changed using loadkeys(1)).
32
33 This system call will fail (with EINVAL) unless magic equals
34 LINUX_REBOOT_MAGIC1 (that is, 0xfee1dead) and magic2 equals
35 LINUX_REBOOT_MAGIC2 (that is, 672274793). However, since 2.1.17 also
36 LINUX_REBOOT_MAGIC2A (that is, 85072278) and since 2.1.97 also
37 LINUX_REBOOT_MAGIC2B (that is, 369367448) and since 2.5.71 also
38 LINUX_REBOOT_MAGIC2C (that is, 537993216) are permitted as value for
39 magic2. (The hexadecimal values of these constants are meaningful.)
40 The cmd argument can have the following values:
41
42 LINUX_REBOOT_CMD_CAD_OFF
43 (RB_DISABLE_CAD, 0). CAD is disabled. This means that the CAD
44 keystroke will cause a SIGINT signal to be sent to init (process
45 1), whereupon this process may decide upon a proper action
46 (maybe: kill all processes, sync, reboot).
47
48 LINUX_REBOOT_CMD_CAD_ON
49 (RB_ENABLE_CAD, 0x89abcdef). CAD is enabled. This means that
50 the CAD keystroke will immediately cause the action associated
51 with LINUX_REBOOT_CMD_RESTART.
52
53 LINUX_REBOOT_CMD_HALT
54 (RB_HALT_SYSTEM, 0xcdef0123; since 1.1.76). The message "System
55 halted." is printed, and the system is halted. Control is given
56 to the ROM monitor, if there is one. If not preceded by a
57 sync(2), data will be lost.
58
59 LINUX_REBOOT_CMD_KEXEC (since Linux 2.6.13)
60 Execute a kernel that has been loaded earlier with
61 kexec_load(2). This option is available only if the kernel was
62 configured with CONFIG_KEXEC.
63
64 LINUX_REBOOT_CMD_POWER_OFF
65 (0x4321fedc; since 2.1.30). The message "Power down." is
66 printed, the system is stopped, and all power is removed from
67 the system, if possible. If not preceded by a sync(2), data
68 will be lost.
69
70 LINUX_REBOOT_CMD_RESTART
71 (RB_AUTOBOOT, 0x1234567). The message "Restarting system." is
72 printed, and a default restart is performed immediately. If not
73 preceded by a sync(2), data will be lost.
74
75 LINUX_REBOOT_CMD_RESTART2
76 (0xa1b2c3d4; since 2.1.30). The message "Restarting system with
77 command '%s'" is printed, and a restart (using the command
78 string given in arg) is performed immediately. If not preceded
79 by a sync(2), data will be lost.
80
81 Only the superuser may call reboot().
82
83 The precise effect of the above actions depends on the architecture.
84 For the i386 architecture, the additional argument does not do anything
85 at present (2.1.122), but the type of reboot can be determined by ker‐
86 nel command-line arguments ("reboot=...") to be either warm or cold,
87 and either hard or through the BIOS.
88
90 For the values of cmd that stop or restart the system, a successful
91 call to reboot() does not return. For the other cmd values, zero is
92 returned on success. In all cases, -1 is returned on failure, and
93 errno is set appropriately.
94
96 EFAULT Problem with getting user-space data under
97 LINUX_REBOOT_CMD_RESTART2.
98
99 EINVAL Bad magic numbers or cmd.
100
101 EPERM The calling process has insufficient privilege to call reboot();
102 the CAP_SYS_BOOT capability is required.
103
105 reboot() is Linux-specific, and should not be used in programs intended
106 to be portable.
107
109 sync(2), bootparam(7), capabilities(7), ctrlaltdel(8), halt(8),
110 reboot(8)
111
113 This page is part of release 3.53 of the Linux man-pages project. A
114 description of the project, and information about reporting bugs, can
115 be found at http://www.kernel.org/doc/man-pages/.
116
117
118
119Linux 2010-10-31 REBOOT(2)