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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

CONFORMING TO

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

SEE ALSO

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

COLOPHON

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