Linux x86-64 compiling and statically linking with gcc I have:
#include <sys/reboot.h>
if (str[0] == 'r')
reboot(0x1234567);
but I can't seem to find the equivalent function call for shutdown. I'd also like to know the llvm function if different.
From sys/reboot.h
:
/* Perform a hard reset now. */
#define RB_AUTOBOOT 0x01234567
[...]
/* Stop system and switch power off if possible. */
#define RB_POWER_OFF 0x4321fedc
So reboot(0x4321fedc);
or reboot(RB_POWER_OFF);
should work.