Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/shell/command/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use help::Helper;
use libc::{reboot, LINUX_REBOOT_CMD_RESTART};
use std::collections::HashMap;
use std::os::fd::{AsFd, AsRawFd};
use std::os::unix::process::CommandExt;
Expand Down Expand Up @@ -169,7 +170,14 @@ impl BuildInCmd {

fn shell_cmd_reboot(args: &Vec<String>) -> Result<(), ExecuteErrorType> {
if args.len() == 0 {
unsafe { libc::syscall(libc::SYS_reboot, 0, 0, 0, 0, 0, 0) };
// 调用 reboot 系统调用
unsafe {
let result = reboot(LINUX_REBOOT_CMD_RESTART);
if result == -1 {
eprintln!("Failed to reboot: {}", std::io::Error::last_os_error());
return Err(ExecuteErrorType::ExecuteFailed);
}
}
return Ok(());
} else {
return Err(ExecuteErrorType::TooManyArguments);
Expand Down
Loading