summaryrefslogtreecommitdiff
path: root/lib/igt_sysrq.c
blob: 3bda321f7c5b60362e19914ecf4ac2ed25374beb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/reboot.h>

#include "igt_core.h"

#include "igt_sysrq.h"

/**
 * igt_sysrq_reboot: Reboots the machine
 *
 * Syncs filesystems and immediately reboots the machine.
 */
void igt_sysrq_reboot(void)
{
	sync();

	/* Try to be nice at first, and if that fails pull the trigger */
	if (reboot(RB_AUTOBOOT)) {
		int fd = open("/proc/sysrq-trigger", O_WRONLY);
		igt_ignore_warn(write(fd, "b", 2));
		close(fd);
	}

	abort();
}