简体   繁体   中英

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? 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. You'll need to include <unistd.h> .

I'm assuming this is available on Mac OS; it should be on all POSIX platforms.

UPDATE

It appears that Mac OS has a reboot system call. 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

:-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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