1REBOOT(2)                  Linux Programmer's Manual                 REBOOT(2)
2
3
4

NAME

6       reboot - reboot or enable/disable Ctrl-Alt-Del
7

SYNOPSIS

9       /* Since kernel version 2.1.30 there are symbolic names LINUX_REBOOT_*
10          for the constants and a fourth argument to the call: */
11
12       #include <unistd.h>
13       #include <linux/reboot.h>
14
15       int reboot(int magic, int magic2, int cmd, void *arg);
16
17       /* Under glibc and most alternative libc's (including uclibc, dietlibc,
18          musl and a few others), some of the constants involved have gotten
19          symbolic names RB_*, and the library call is a 1-argument
20          wrapper around the system call: */
21
22       #include <unistd.h>
23       #include <sys/reboot.h>
24
25       int reboot(int cmd);
26

DESCRIPTION

28       The  reboot()  call  reboots the system, or enables/disables the reboot
29       keystroke (abbreviated CAD, since the default  is  Ctrl-Alt-Delete;  it
30       can be changed using loadkeys(1)).
31
32       This  system  call  fails  (with  the error EINVAL) unless magic equals
33       LINUX_REBOOT_MAGIC1 (that is, 0xfee1dead) and magic2  equals  LINUX_RE‐
34       BOOT_MAGIC2 (that is, 672274793).  However, since 2.1.17 also LINUX_RE‐
35       BOOT_MAGIC2A (that  is,  85072278)  and  since  2.1.97  also  LINUX_RE‐
36       BOOT_MAGIC2B  (that  is,  369367448)  and  since  2.5.71 also LINUX_RE‐
37       BOOT_MAGIC2C (that is, 537993216) are permitted as values  for  magic2.
38       (The hexadecimal values of these constants are meaningful.)
39
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 Linux 1.1.76).   The  message
55              "System  halted." is printed, and the system is halted.  Control
56              is given to the ROM monitor, if there is one.  If  not  preceded
57              by a sync(2), data will be lost.
58
59       LINUX_REBOOT_CMD_KEXEC
60              (RB_KEXEC,  0x45584543,  since  Linux 2.6.13).  Execute a kernel
61              that has been loaded earlier with kexec_load(2).  This option is
62              available only if the kernel was configured with CONFIG_KEXEC.
63
64       LINUX_REBOOT_CMD_POWER_OFF
65              (RB_POWER_OFF,  0x4321fedc;  since  Linux  2.1.30).  The message
66              "Power down." is printed, the system is stopped, and  all  power
67              is  removed  from the system, if possible.  If not preceded by a
68              sync(2), data 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 Linux 2.1.30).  The message "Restarting  sys‐
77              tem with command '%s'" is printed, and a restart (using the com‐
78              mand string given in arg) is performed immediately.  If not pre‐
79              ceded by a sync(2), data will be lost.
80
81       LINUX_REBOOT_CMD_SW_SUSPEND
82              (RB_SW_SUSPEND,  0xd000fce1; since Linux 2.5.18).  The system is
83              suspended (hibernated) to disk.  This option is  available  only
84              if the kernel was configured with CONFIG_HIBERNATION.
85
86       Only the superuser may call reboot().
87
88       The  precise  effect  of the above actions depends on the architecture.
89       For the i386 architecture, the additional argument does not do anything
90       at  present (2.1.122), but the type of reboot can be determined by ker‐
91       nel command-line arguments ("reboot=...") to be either  warm  or  cold,
92       and either hard or through the BIOS.
93
94   Behavior inside PID namespaces
95       Since  Linux 3.4, if reboot() is called from a PID namespace other than
96       the initial PID namespace with one of the cmd values listed  below,  it
97       performs  a  "reboot"  of that namespace: the "init" process of the PID
98       namespace is immediately terminated,  with  the  effects  described  in
99       pid_namespaces(7).
100
101       The  values  that  can be supplied in cmd when calling reboot() in this
102       case are as follows:
103
104       LINUX_REBOOT_CMD_RESTART, LINUX_REBOOT_CMD_RESTART2
105              The "init" process is terminated,  and  wait(2)  in  the  parent
106              process reports that the child was killed with a SIGHUP signal.
107
108       LINUX_REBOOT_CMD_POWER_OFF, LINUX_REBOOT_CMD_HALT
109              The  "init"  process  is  terminated,  and wait(2) in the parent
110              process reports that the child was killed with a SIGINT signal.
111
112       For the other cmd values, reboot() returns -1 and errno is set to  EIN‐
113       VAL.
114

RETURN VALUE

116       For  the  values  of  cmd that stop or restart the system, a successful
117       call to reboot() does not return.  For the other cmd  values,  zero  is
118       returned  on success.  In all cases, -1 is returned on failure, and er‐
119       rno is set appropriately.
120

ERRORS

122       EFAULT Problem   with   getting   user-space   data   under   LINUX_RE‐
123              BOOT_CMD_RESTART2.
124
125       EINVAL Bad magic numbers or cmd.
126
127       EPERM  The calling process has insufficient privilege to call reboot();
128              the caller must have the CAP_SYS_BOOT inside its user namespace.
129

CONFORMING TO

131       reboot() is Linux-specific, and should not be used in programs intended
132       to be portable.
133

SEE ALSO

135       systemctl(1),  systemd(1),  kexec_load(2), sync(2), bootparam(7), capa‐
136       bilities(7), ctrlaltdel(8), halt(8), shutdown(8)
137

COLOPHON

139       This page is part of release 5.10 of the Linux  man-pages  project.   A
140       description  of  the project, information about reporting bugs, and the
141       latest    version    of    this    page,    can     be     found     at
142       https://www.kernel.org/doc/man-pages/.
143
144
145
146Linux                             2019-03-06                         REBOOT(2)
Impressum