reboot -重新启动或启用/禁用按Ctrl-Alt-Del键

内容简介

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

#include

int reboot(intmagic, intmagic2, intflag, 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

#include

int reboot(intflag);

描述

Thereboot() call reboots the system, or enables/disables the reboot keystroke (abbreviated CAD, since the default is Ctrl-Alt-Delete; it can be changed usingloadkeys(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 flag 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 async(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 processes, sync, reboot).

Only the superuser may use this function.

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.

返回值

On success, zero is returned. On error, -1 is returned, anderrnois set appropriately.

错误

标签

描述

EFAULT

Problem with getting userspace data under LINUX_REBOOT_CMD_RESTART2.

EINVAL

Bad magic numbers or flag.

EPERM

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

遵循于

reboot()是Linux特有的,并应在拟移植的程序不能使用。

另请参阅

¥ 我要打赏

纠错/补充

收藏

加QQ群啦,易百教程官方技术学习群

注意:建议每个人选自己的技术方向加群,同一个QQ最多限加 3 个群。

linux中reboot函数在哪,reboot()函数 Unix/Linux相关推荐

  1. linux中root所属的组的gid为,linux用户和用户组

    1.用户和用户组概念 回到顶部 Linux是典型的多用户多任务操作系统,在使用linux操作系统之前,必须首先向系统管理员申请账号,然后通过帐号登录系统. 用户在登录时键入正确的用户名和口令后,即可进 ...

  2. linux存放脚本目录,linux中Shell脚本所在目录的绝对路径linux操作系统 -电脑资料...

    linux shell 脚本里面如果想得到当前脚本文件存放的绝对路径,也没有太现成的命令可以调用,不过可以通过下面的语句来获取:代码如下复制代码 baseDirForScriptSelf=$(cd & ...

  3. Linux绘图函数与驱动,Linux中与驱动相关的ioctl函数

    一:    ioctl函数的作用 ioctl用于向设备发控制和配置命令 ,有些命令也需要读写一些数据,但这些数据是不能用read/write读写的,称为Out-of-band数据.也就是说,read/ ...

  4. Linux中如何使用mysql和php_hi 感恩节——Linux基础教程之mysql和php

    感恩节.虽然一直没有过这个节日的习惯,但仅仅是听到感恩的消息,都能想到一幅幅画面.愿大家安好! 学习Linux的前言 选择了Linux发行版本,你就会想如何开始学习Linux了. 1.当然是安装Lin ...

  5. linux中rm删除的文件是否可以恢复,Linux下用rm删除的文件的恢复方法

    Linux下用rm删除的文件的恢复方法_Linux教程_Linux公社-Linux系统门户网站 https://www.linuxidc.com/Linux/2008-08/14744.htm lin ...

  6. linux中的ftp是什么意思,什么是linux的ftp

    vsftpd是一款在Linux发行版中最受推崇的FTP服务器程序. 特点是小巧轻快,安全易用.并且是一个完全免费开放源码的ftp软件 ftp的作用: FTP(File Transfer Protoco ...

  7. openssl生成证书linux,linux中openssl生成证书和自签证书linux操作系统 -电脑资料

    下面来给大家介绍关于linux中openssl生成证书和自签证书的例子,整个过程都讲述的非常详细有兴趣的朋友可进入参考, 1.首先要生成服务器端的私钥(key文件):代码如下复制代码 openssl ...

  8. linux中85379端口如何恢复,技术|如何在 Linux/Unix 系统中验证端口是否打开

    在 Linux 或者类 Unix 中,我该如何检查某个端口是否被占用?我又该如何验证 Linux 服务器中有哪些端口处于监听状态? 验证哪些端口在服务器的网络接口上处于监听状态是非常重要的.你需要注意 ...

  9. 在Linux中GNU的名词解释,GNU在GNU / Linux操作系统中的主要贡献是什么...

    除了vonbrand的答案之外,让我们不要忘记对GNU / Linux操作系统的一个主要贡献是,很多GNU的东西已经存在,已经在整个生态系统中运行,并且在Linux(内核)时可以在开源许可下免费获得项 ...

  10. Linux如何查询目录默认权限,如何设置UNIX/Linux中新创建目录或文件的默认权限

    在unix或者linux中,创建一个新文件或者目录时,这个文件或者目录都具有一个默认的权限,比如目录755,文件644,这些默认权限是由umask(权限掩码)来控制的,一般umask默认值为022,其 ...

最新文章

  1. docker探索-使用docker service管理swarm(十一 )
  2. 10.30T2 二分+前缀和(后缀和)
  3. 任意编程语言访问PostgreSQL:C++接口
  4. php链接远程socket,php使用socket获取远程图片
  5. oracle中exp/imp讲解
  6. 用 Python 实现溺水识别
  7. pajek软件使用方法_双全科技|管家婆管理库存必备“序列号”,管家婆软件的使用方法...
  8. kali破解WiFi时wlan0没有变wlan0mon_黑客入门干货:黑客使用 Aircrack-ng 破解 Wi-Fi 密码
  9. 萌新向Python数据分析及数据挖掘 第二章 pandas 第二节 Python Language Basics, IPython, and Jupyter Notebooks...
  10. 使用ember-cli脚手架快速构建项目
  11. python pickle库_Python使用Pickle库实现读写序列操作示例
  12. vasp-分子动力学模拟
  13. 2021-07-14 西门子PLC编程软件--博途V14软件的安装
  14. 2022年安全员-A证考试模拟100题模拟考试平台操作
  15. 「AI」一文看懂“声纹识别VPR”
  16. js图片添加文字水印并设置水印居中的方法
  17. 《自然语言处理-基于预训练模型的方法》笔记
  18. win 7 与 virtualbox ubuntu 共享文件夹
  19. 用Google实现站内搜索
  20. php warning require,Thinkphp 网站打开提示Warning: require(): open_basedir restriction in effect另一种解决方法...

热门文章

  1. C++ 多态性 (polymorphism)
  2. 首家新三板上市区块链公司:他们提供面向政务、商务、公众等解决方案
  3. python(十)——文件读写、OS模块、win32控制窗体、语音合成
  4. 华为AI Gallery社区《基于机器学习的欧洲杯赛事预测》技术分析系列——(一)基本原理
  5. Swift中MVP、Moya、模型设计
  6. 用matlab 计算范德蒙德行列式,行列式计算范德蒙德行列式
  7. ts版操作localStorage和sessionStorage工具
  8. python实现论文查重系统_Python实现的检测网站挂马程序
  9. 雷军博客分享-日本的电饭煲到底好在哪?
  10. ptp输出内容包含什么_解剖PTP协议