简体   繁体   English

使用C ++调用不正常地重新启动Mac OS X?

[英]Restart Mac OS X ungracefully using a C++ call?

How do I restart Mac OS X using C++ ( not Objetive-C ) without invoking any child processes? 如何在不调用任何子进程的情况下使用C ++不是Objetive-C )重新启动Mac OS X? Don't care if it's ungraceful . 不管它是否不合时宜

system("reboot"); //Is not acceptable as it relies on invoking a process

I can't think why you wouldn't want to create a new process, but if you really don't want to, then execve("reboot",0,0) will run reboot , replacing the current process. 我不知道为什么您不想创建一个新进程,但是如果您确实不想创建新进程,那么execve("reboot",0,0)将运行reboot ,从而替换当前进程。 You'll need to include <unistd.h> . 您需要包含<unistd.h>

I'm assuming this is available on Mac OS; 我假设这在Mac OS上可用; it should be on all POSIX platforms. 它应该在所有POSIX平台上。

UPDATE 更新

It appears that Mac OS has a reboot system call. 看来Mac OS具有reboot系统调用。 reboot(RB_AUTOBOOT); might do what you want. 可能会做您想要的。 Or it might trash your hard drive. 否则可能会损坏您的硬盘。 Be very careful when trying to work against the operating system like this. 尝试像这样在操作系统上工作时要非常小心。

JMP 0xFFFF0 JMP 0xFFFF0

:-) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM