diff options
author | root <root@avtech.domain.avtechpulse.com> | 1999-12-31 19:02:07 -0500 |
---|---|---|
committer | root <root@avtech.domain.avtechpulse.com> | 1999-12-31 19:02:07 -0500 |
commit | 0663574945e000c7fd7a78add7e38f8e5c7796fe (patch) | |
tree | 5e3bcdfbfd443c945aa7af5ad1bf18c4a2208505 | |
parent | 5f9b655fe0945da3dde52fe62950a1e6d168ca5c (diff) |
fix magic sysrq file-open flags, change sync/ro order
-rw-r--r-- | instr-daemon.c | 13 |
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); } |