【发布时间】:2021-09-03 09:14:47
【问题描述】:
我有一个小型 cpp 应用程序,它将重新启动系统。到目前为止,这非常有效。
sync(); //need for data safety
reboot(RB_AUTOBOOT);
除非您通过 SSH 连接并在连接的设备上运行此程序。然后 SSH 连接挂起。
如果您通过 SSH 连接并使用 CLI 命令
sudo reboot
或
sudo shutdown -r now
SSH 连接将终止并显示以下消息
Connection to xxx.xxx.xxx.xxx closed by remote host.
Connection to xxx.xxx.xxx.xxx closed.
如何使用 cpp reboot 方法获得相同的行为?
我阅读了https://man7.org/linux/man-pages/man2/reboot.2.html 并搜索了互联网,但没有找到有关此主题的信息。
【问题讨论】:
标签: c++ linux ssh debian-based