shithub: patch

ref: 6a44dcea2cfd720f5a772e4971d8fc832f22043f
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();