1 #include <unistd.h>
2 #include <fcntl.h>
3 #include <stdlib.h>
4 #include <sys/reboot.h>
5 
6 #include "igt_core.h"
7 
8 #include "igt_sysrq.h"
9 
10 /**
11  * igt_sysrq_reboot: Reboots the machine
12  *
13  * Syncs filesystems and immediately reboots the machine.
14  */
igt_sysrq_reboot(void)15 void igt_sysrq_reboot(void)
16 {
17 	sync();
18 
19 	/* Try to be nice at first, and if that fails pull the trigger */
20 	if (reboot(RB_AUTOBOOT)) {
21 		int fd = open("/proc/sysrq-trigger", O_WRONLY);
22 		igt_ignore_warn(write(fd, "b", 2));
23 		close(fd);
24 	}
25 
26 	abort();
27 }
28