REBOOT(2) Linux Programmer's Manual REBOOT(2)

NAME

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

SYNOPSIS

/* For libc4 and libc5 the library call and the system call
are identical, and since kernel version 2.1.30 there are
symbolic names LINUX_REBOOT_* for the constants and a
fourth argument to the call: */

#include <unistd.h>
#include <linux/reboot.h>

int reboot(int magic, int magic2, int cmd, void *arg);

/* Under glibc some of the constants involved have gotten
symbolic names RB_*, and the library call is a 1-argument
wrapper around the 3-argument system call: */

#include <unistd.h>
#include <sys/reboot.h>

int reboot(int cmd);

DESCRIPTION

The reboot() call reboots the system, or enables/disables the reboot keystroke (abbreviated CAD, since the default
is Ctrl-Alt-Delete; it can be changed using loadkeys(1)).

This system call will fail (with EINVAL) unless magic equals LINUX_REBOOT_MAGIC1 (that is, 0xfee1dead) and magic2
equals LINUX_REBOOT_MAGIC2 (that is, 672274793). However, since 2.1.17 also LINUX_REBOOT_MAGIC2A (that is,
85072278) and since 2.1.97 also LINUX_REBOOT_MAGIC2B (that is, 369367448) and since 2.5.71 also
LINUX_REBOOT_MAGIC2C (that is, 537993216) are permitted as value for magic2. (The hexadecimal values of these
constants are meaningful.) The cmd argument can have the following values:

LINUX_REBOOT_CMD_RESTART
(RB_AUTOBOOT, 0x1234567). The message "Restarting system." is printed, and a default restart is performed
immediately. If not preceded by a sync(2), data will be lost.

LINUX_REBOOT_CMD_HALT
(RB_HALT_SYSTEM, 0xcdef0123; since 1.1.76). The message "System halted." is printed, and the system is
halted. Control is given to the ROM monitor, if there is one. If not preceded by a sync(2), data will be
lost.

LINUX_REBOOT_CMD_POWER_OFF
(0x4321fedc; since 2.1.30). The message "Power down." is printed, the system is stopped, and all power is
removed from the system, if possible. If not preceded by a sync(2), data will be lost.

LINUX_REBOOT_CMD_RESTART2
(0xa1b2c3d4; since 2.1.30). The message "Restarting system with command '%s'" is printed, and a restart
(using the command string given in arg) is performed immediately. If not preceded by a sync(2), data will
be lost.

LINUX_REBOOT_CMD_CAD_ON
(RB_ENABLE_CAD, 0x89abcdef). CAD is enabled. This means that the CAD keystroke will immediately cause the
action associated with LINUX_REBOOT_CMD_RESTART.

LINUX_REBOOT_CMD_CAD_OFF
(RB_DISABLE_CAD, 0). CAD is disabled. This means that the CAD keystroke will cause a SIGINT signal to be
sent to init (process 1), whereupon this process may decide upon a proper action (maybe: kill all pro‐
cesses, sync, reboot).

Only the superuser may call reboot().

The precise effect of the above actions depends on the architecture. For the i386 architecture, the additional
argument does not do anything at present (2.1.122), but the type of reboot can be determined by kernel command-
line arguments ("reboot=...") to be either warm or cold, and either hard or through the BIOS.

RETURN VALUE

For the values of cmd that stop or restart the system, a successful call to reboot() does not return. For the
other cmd values, zero is returned on success. In all cases, -1 is returned on failure, and errno is set appro‐
priately.

ERRORS

EFAULT Problem with getting userspace data under LINUX_REBOOT_CMD_RESTART2.

EINVAL Bad magic numbers or cmd.

EPERM The calling process has insufficient privilege to call reboot(); the CAP_SYS_BOOT capability is required.

CONFORMING TO

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

SEE ALSO

sync(2), bootparam(7), capabilities(7), ctrlaltdel(8), halt(8), reboot(8)

COLOPHON

This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information
about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.

Linux 2008-02-11 REBOOT(2)

Linux Programmer's Manual --- reboot的更多相关文章

  1. Linux User's Manual IOSTAT

    IOSTAT(1) Linux User's Manual IOSTAT(1) NAME iostat - Report Central Processing Unit (CPU) statistic ...

  2. 基于linux与busybox的reboot命令流程分析

    http://www.xuebuyuan.com/736763.html 基于Linux与Busybox的Reboot命令流程分析 ********************************** ...

  3. Linux开关命令(shutdown,reboot,halt,init)

    命令简短 shutdown,poweroff,reboot,halt,init都能够进行关机,大致使用方法. /sbin/halt     [-n] [-w] [-d] [-f] [-i] [-p] ...

  4. HTB Linux queuing discipline manual - user guide笔记

    1. Introduction HTB is meant as a more understandable, intuitive and faster replacement for the CBQ ...

  5. linux下c程序调用reboot函数实现直接重启【转】

    转自:http://www.blog.chinaunix.net/uid-20564848-id-73878.html linux下c程序调用reboot函数实现直接重启 当然你也可以直接调用syst ...

  6. #include <sys/epoll.h> epoll - I/O event notification facility 服务器端 epoll(7) - Linux manual page http://www.man7.org/linux/man-pages/man7/epoll.7.html

    epoll使用详解(精髓) - Boblim - 博客园 https://www.cnblogs.com/fnlingnzb-learner/p/5835573.html epoll使用详解(精髓) ...

  7. Linux fstab 参数详解

    [root@qs-wg-db1 /]# cat /etc/fstab LABEL=/          /                       ext3    defaults         ...

  8. 【linux草鞋应用编程系列】_6_ 重定向和VT100编程

    一.文件重定向     我们知道在linux shell 编程的时候,可以使用文件重定向功能,如下所示: [root@localhost pipe]# echo "hello world&q ...

  9. 【linux草鞋应用编程系列】_5_ Linux网络编程

    一.网络通信简介   第一部分内容,暂时没法描述,内容实在太多,待后续专门的系列文章.   二.linux网络通信     在linux中继承了Unix下“一切皆文件”的思想, 在linux中要实现网 ...

随机推荐

  1. KMP与循环节相关题目

    HDU 3746 Cyclic Nacklace ( KMP求最小循环节 ) len - nextval[len]即为最小循环节长度. #include <cstdio> #include ...

  2. HDU 3577 Fast Arrangement ( 线段树 成段更新 区间最值 区间最大覆盖次数 )

    线段树成段更新+区间最值. 注意某人的乘车区间是[a, b-1],因为他在b站就下车了. #include <cstdio> #include <cstring> #inclu ...

  3. js中prop和attr区别

    首先 attr 是从页面搜索获得元素值,所以页面必须明确定义元素才能获取值,相对来说比较慢. 如: <input name='test' type='checkbox'> $('input ...

  4. [2018-9-4T2]探索黑暗dark

    题目大意:有一棵树,第$i$个点的点权为$s_i(s_1>0)$.初始有每个点都是亮的.$m$次修改,每次改变一个点的亮暗,回答包含$1$的全亮的连通块中点权和最大的连通块的和的值. 题解:正解 ...

  5. BZOJ5297 [Cqoi2018]社交网络 【矩阵树定理】

    题目链接 BZOJ5297 题解 最近这玩意这么那么火 这题要用到有向图的矩阵树定理 主对角线上对应入度 剩余位置如果有边则为\(-1\),不然为\(0\) \(M_{i,i}\)即为以\(i\)为根 ...

  6. Tomcat学习笔记(六)

    Tomcat日志 网上找到一篇分析不错的博文   http://peiquan.blog.51cto.com/7518552/1580189/

  7. 在本地文件当中package.json的作用

    除了常见的指定包的相关依赖,一些包的相关信息之外 main: 它是用来指定当前包的入口文件,容易让人忽视的一点是它不仅仅在发布的npm包当中有用,在你的业务代码当中也具有一样的作用. 例如,我需要一个 ...

  8. c/c++: c++函数返回类型什么情况带const

    c++ 函数的返回类型,包括const 什么时候起作用呢? 函数返回值不想其立即修改的. 例子如下,这是一个简单的避免产生隐形返回变量的方法,abc 的函数返回是引用,main函数中第10行,++ 操 ...

  9. Secret Cow code(USACO)

    题目描述:zxyer为了防止他的标程被别人抄走,他在计算机中的rar文件上设置了一个密码,其中每一个密码都有一个初始字符串,字符串由大写字母组成,且长度不超过30位,每一个密码还有一个询问,询问为一个 ...

  10. zmap zgrab 环境搭建

    yum install cmake gmp-devel gengetopt libpcap-devel flex byacc json-c-devel libunistring-devel golan ...