1reboot(2)                     System Calls Manual                    reboot(2)
2
3
4

NAME

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

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

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

DESCRIPTION

32       The  reboot()  call  reboots the system, or enables/disables the reboot
33       keystroke (abbreviated CAD, since the default  is  Ctrl-Alt-Delete;  it
34       can be changed using loadkeys(1)).
35
36       This  system  call  fails  (with  the error EINVAL) unless magic equals
37       LINUX_REBOOT_MAGIC1 (that is, 0xfee1dead) and magic2  equals  LINUX_RE‐
38       BOOT_MAGIC2  (that  is,  0x28121969).  However, since Linux 2.1.17 also
39       LINUX_REBOOT_MAGIC2A (that is, 0x05121996) and since Linux 2.1.97  also
40       LINUX_REBOOT_MAGIC2B  (that is, 0x16041998) and since Linux 2.5.71 also
41       LINUX_REBOOT_MAGIC2C (that is, 0x20112000) are permitted as values  for
42       magic2.  (The hexadecimal values of these constants are meaningful.)
43
44       The cmd argument can have the following values:
45
46       LINUX_REBOOT_CMD_CAD_OFF
47              (RB_DISABLE_CAD,  0).  CAD is disabled.  This means that the CAD
48              keystroke will cause a SIGINT signal to be sent to init (process
49              1),  whereupon  this  process  may  decide  upon a proper action
50              (maybe: kill all processes, sync, reboot).
51
52       LINUX_REBOOT_CMD_CAD_ON
53              (RB_ENABLE_CAD, 0x89abcdef).  CAD is enabled.  This  means  that
54              the  CAD  keystroke will immediately cause the action associated
55              with LINUX_REBOOT_CMD_RESTART.
56
57       LINUX_REBOOT_CMD_HALT
58              (RB_HALT_SYSTEM, 0xcdef0123; since Linux 1.1.76).   The  message
59              "System  halted." is printed, and the system is halted.  Control
60              is given to the ROM monitor, if there is one.  If  not  preceded
61              by a sync(2), data will be lost.
62
63       LINUX_REBOOT_CMD_KEXEC
64              (RB_KEXEC,  0x45584543,  since  Linux 2.6.13).  Execute a kernel
65              that has been loaded earlier with kexec_load(2).  This option is
66              available only if the kernel was configured with CONFIG_KEXEC.
67
68       LINUX_REBOOT_CMD_POWER_OFF
69              (RB_POWER_OFF,  0x4321fedc;  since  Linux  2.1.30).  The message
70              "Power down." is printed, the system is stopped, and  all  power
71              is  removed  from the system, if possible.  If not preceded by a
72              sync(2), data will be lost.
73
74       LINUX_REBOOT_CMD_RESTART
75              (RB_AUTOBOOT, 0x1234567).  The message "Restarting  system."  is
76              printed, and a default restart is performed immediately.  If not
77              preceded by a sync(2), data will be lost.
78
79       LINUX_REBOOT_CMD_RESTART2
80              (0xa1b2c3d4; since Linux 2.1.30).  The message "Restarting  sys‐
81              tem with command '%s'" is printed, and a restart (using the com‐
82              mand string given in arg) is performed immediately.  If not pre‐
83              ceded by a sync(2), data will be lost.
84
85       LINUX_REBOOT_CMD_SW_SUSPEND
86              (RB_SW_SUSPEND,  0xd000fce1; since Linux 2.5.18).  The system is
87              suspended (hibernated) to disk.  This option is  available  only
88              if the kernel was configured with CONFIG_HIBERNATION.
89
90       Only the superuser may call reboot().
91
92       The  precise  effect  of the above actions depends on the architecture.
93       For the i386 architecture, the additional argument does not do anything
94       at  present (2.1.122), but the type of reboot can be determined by ker‐
95       nel command-line arguments ("reboot=...") to be either  warm  or  cold,
96       and either hard or through the BIOS.
97
98   Behavior inside PID namespaces
99       Since  Linux 3.4, if reboot() is called from a PID namespace other than
100       the initial PID namespace with one of the cmd values listed  below,  it
101       performs  a  "reboot"  of that namespace: the "init" process of the PID
102       namespace is immediately terminated,  with  the  effects  described  in
103       pid_namespaces(7).
104
105       The  values  that  can be supplied in cmd when calling reboot() in this
106       case are as follows:
107
108       LINUX_REBOOT_CMD_RESTART, LINUX_REBOOT_CMD_RESTART2
109              The "init" process is terminated,  and  wait(2)  in  the  parent
110              process reports that the child was killed with a SIGHUP signal.
111
112       LINUX_REBOOT_CMD_POWER_OFF, LINUX_REBOOT_CMD_HALT
113              The  "init"  process  is  terminated,  and wait(2) in the parent
114              process reports that the child was killed with a SIGINT signal.
115
116       For the other cmd values, reboot() returns -1 and errno is set to  EIN‐
117       VAL.
118

RETURN VALUE

120       For  the  values  of  cmd that stop or restart the system, a successful
121       call to reboot() does not return.  For the other cmd  values,  zero  is
122       returned  on success.  In all cases, -1 is returned on failure, and er‐
123       rno is set to indicate the error.
124

ERRORS

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

STANDARDS

135       Linux.
136

SEE ALSO

138       systemctl(1), systemd(1), kexec_load(2), sync(2),  bootparam(7),  capa‐
139       bilities(7), ctrlaltdel(8), halt(8), shutdown(8)
140
141
142
143Linux man-pages 6.04              2023-03-30                         reboot(2)
Impressum