summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--instr-daemon.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/instr-daemon.c b/instr-daemon.c
index 7b85636..5258362 100644
--- a/instr-daemon.c
+++ b/instr-daemon.c
@@ -331,20 +331,23 @@ static gboolean periodic_poll (void)
LCD_write(0,0,"Power failed. Shutdown.");
// use plain old open to avoid any buffering etc
- int enablefd = open("/proc/sys/kernel/sysrq", O_SYNC, O_RDWR);
- int trgfd = open("/proc/sysrq-trigger", O_SYNC, O_RDWR);
+ int enablefd = open("/proc/sys/kernel/sysrq", O_SYNC | O_RDWR);
+ int trgfd = open("/proc/sysrq-trigger", O_SYNC | O_RDWR);
// enable sysrq
write(enablefd, "1\n", 2);
-
- // remount ro
- write(trgfd, "u\n", 2);
+ close(enablefd);
// sync disks
write(trgfd, "s\n", 2);
+ // remount ro
+ write(trgfd, "u\n", 2);
+ close(trgfd);
+
// poweroff
system ("/usr/bin/systemctl poweroff -f");
+
exit(0);
}