summary refs log tree commit diff
path: root/bin/ptee.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/ptee.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/ptee.c b/bin/ptee.c
index ee035e8a..94be3037 100644
--- a/bin/ptee.c
+++ b/bin/ptee.c
@@ -16,6 +16,7 @@
 
 #include <err.h>
 #include <poll.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
@@ -65,6 +66,8 @@ int main(int argc, char *argv[]) {
 		err(EX_NOINPUT, "%s", argv[1]);
 	}
 
+	bool stop = false;
+
 	byte buf[4096];
 	struct pollfd fds[2] = {
 		{ .events = POLLIN, .fd = STDIN_FILENO },
@@ -74,6 +77,12 @@ int main(int argc, char *argv[]) {
 		if (fds[0].revents & POLLIN) {
 			ssize_t rlen = read(STDIN_FILENO, buf, sizeof(buf));
 			if (rlen < 0) err(EX_IOERR, "read");
+
+			if (rlen == 1 && buf[0] == CTRL('S')) {
+				stop ^= true;
+				continue;
+			}
+
 			ssize_t wlen = write(pty, buf, rlen);
 			if (wlen < 0) err(EX_IOERR, "write");
 		}
@@ -85,8 +94,10 @@ int main(int argc, char *argv[]) {
 			ssize_t wlen = write(STDIN_FILENO, buf, rlen);
 			if (wlen < 0) err(EX_IOERR, "write");
 
-			wlen = write(STDOUT_FILENO, buf, rlen);
-			if (wlen < 0) err(EX_IOERR, "write");
+			if (!stop) {
+				wlen = write(STDOUT_FILENO, buf, rlen);
+				if (wlen < 0) err(EX_IOERR, "write");
+			}
 		}
 
 		int status;
'>Remove modified sensitivity settingsJune McEnroe 2020-10-29Remove editJune McEnroe 2020-10-27Switch gr alias back to git rebaseJune McEnroe 2020-10-27Allow cd host: to cd to same path over sshJune McEnroe 2020-10-27Use SendEnv for cd host:pathJune McEnroe 2020-10-27Allow cd host:path over sshJune McEnroe 2020-10-07Use mandoc -T utf8 for text.June McEnroe 2020-09-20Add The Awakened KingdomJune McEnroe 2020-09-12Move /opt/local back, cheat port select to use system manJune McEnroe 2020-09-12Move /opt/local behind /usr againJune McEnroe 2020-09-12Enable toc in cgit renderings of man pagesJune McEnroe 2020-09-11Install mandoc on macOSJune McEnroe 2020-09-11Rewrite install script yet againJune McEnroe 2020-09-11Remove NetBSD from install scriptJune McEnroe 2020-09-11Use MacPorts rather than pkgsrcJune McEnroe 2020-09-11Add debian VM name to sshJune McEnroe 2020-09-11Add influencer tweetJune McEnroe 2020-09-10Add The Kingdom of GodsJune McEnroe 2020-09-07Add SunglassesJune McEnroe 2020-09-06Add Between the BreathsJune McEnroe 2020-09-04Open /dev/tty in nudgeJune McEnroe 2020-09-04Add nudgeJune McEnroe 2020-09-03Build fbclock with -lzJune McEnroe 2020-08-29Add tweets from retweetsJune McEnroe