diff options
Diffstat (limited to 'lib/igt_sysrq.c')
-rw-r--r-- | lib/igt_sysrq.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/igt_sysrq.c b/lib/igt_sysrq.c new file mode 100644 index 00000000..3bda321f --- /dev/null +++ b/lib/igt_sysrq.c @@ -0,0 +1,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(); +} |