shithub: patch

ref: 03e776bc3cb3be7a0dede3de0fb6af99f43b357f
dir: /kbdfs-fshalt/

View raw version
diff -r 70f20d62c396 sys/src/cmd/aux/kbdfs/kbdfs.c
--- a/sys/src/cmd/aux/kbdfs/kbdfs.c	Wed Jan 08 02:35:01 2020 +0000
+++ b/sys/src/cmd/aux/kbdfs/kbdfs.c	Wed Jan 08 06:23:13 2020 +0100
@@ -306,6 +306,24 @@
 }
 
 void
+emergencywarp(void)
+{
+	int fd;
+
+	if(debug)
+		return;
+
+	if(access("#s/cwfs.cmd", AEXIST) == 0 && (fd = eopen("#s/cwfs.cmd", OWRITE)) >= 0){
+		fprint(fd, "halt\n");
+		close(fd);
+	}
+	if(access("#s/hjfs.cmd", AEXIST) == 0 && (fd = eopen("#s/hjfs.cmd", OWRITE)) >= 0){
+		fprint(fd, "halt\n");
+		close(fd);
+	}
+}
+
+void
 reboot(void)
 {
 	int fd;
@@ -387,6 +405,8 @@
 	if(scan->caps && key.r<='z' && key.r>='a')
 		key.r += 'A' - 'a';
 
+	if(scan->ctl && scan->altgr && key.r == Kdel)
+		emergencywarp();
 	if(scan->ctl && scan->alt && key.r == Kdel)
 		reboot();