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. 16个简单实用的.htaccess技巧

    .htaccess 文件 (Hypertext Access file) 是Apache Web服务器的一个非常强大的配置文件,对于这个文件,Apache有一堆参数可以让你配置出几乎随心所欲的功能.. ...

  2. 基于MAC OS 操作系统安装、配置hadoop

    在Mac上安装Hadoop 对我这个之前从未接触过*nix的用户来说,使用命令行来做一系列的事情还是废了一番功夫.特写这个记录,以做备份. 获取Java 我的Mac运行的操作系统是OS X 10.7 ...

  3. GYM - 101147 F.Bishops Alliance

    题意: 一个n*n的棋盘,有m个主教.每个主教都有自己的权值p.给出一个值C,在棋盘中找到一个最大点集.这个点集中的点在同一条对角线上且对于点集中任意两点(i,j),i和j之间的主教数(包括i,j)不 ...

  4. [Atcoder Grand Contest 006 F][AGC006F] Blackout [染色]

    题面 传送门 思路 首先,这个涂黑的方法我们来优化一下模型(毕竟当前这个放到矩形里面,你并看不出来什么规律qwq) 我们令每个行/列编号为一个点,令边(x,y)表示一条从x到y的有向边 那么显然只要有 ...

  5. ubuntu安装出现"删除initramfs-tools时出错",subprocess installed post-installation script returned error exit status 1

    昨日准备重装ubuntu,增大了系统容量,因为前面用到boot分区不到100M,于是这里分区如下 /boot 100M / 30G /home 50G 然后安装快结束时就出现如下图问题 开始以为是镜像 ...

  6. lesson 5

    C#中的委托(delegate)与事件(event) 一.委托就是中间人的意思,c#中的委托允许将一个类中的方法传递给另一个能调用该方法的类的某个对象.程序员可以将A类的一个方法m(被包含在某个del ...

  7. Bzoj2165 大楼

    Time Limit: 40 Sec  Memory Limit: 259 MBSubmit: 779  Solved: 285[Submit][Status][Discuss] Descriptio ...

  8. 汕头市队赛 SRM 09 A 撕书

    A 撕书I-3 SRM 09 背景&&描述 琉璃在撕书.     书总共有n页,都悬浮在数轴上,第i页的位置为,上面写着一个数字.     琉璃从右往左撕书.假如看到了第i页,就把在第 ...

  9. ef unitofwork 主从表更新

    readonly UnitOfWork _u = new UnitOfWork(); public M Get(int id) { return _u.T_MtnContractRepository( ...

  10. fatal error LNK1104: 无法打开文件“LIBC.lib”错误(转)

    原文转自 http://blog.csdn.net/qq1028850792/article/details/41546043 方法一: 用VS2005重新编译某个工程的发生了链接错误,现在把这个解决 ...