commit e156ecc

d_m  ·  2025-03-08 03:47:14 +0000 UTC
parent 5cd55b0
Return EOF when child process is done writing.

When read returns 0 that means that the process is done
writing, and an EOF (0) should be sent to the console.
1 files changed,  +5, -1
+5, -1
 1@@ -248,10 +248,14 @@ emu_run(void)
 2 				XPutImage(display, window, DefaultGC(display, 0), ximage, x, y, x, y, w, h);
 3 			}
 4 		}
 5-		if((fds[2].revents & POLLIN) != 0) {
 6+		int has_input = fds[2].revents & POLLIN;
 7+		int has_eof = fds[2].revents & POLLHUP;
 8+		if(has_input || has_eof) {
 9 			int i = 1, n = read(fds[2].fd, coninp, CONINBUFSIZE - 1);
10 			for(i = 0, coninp[n] = 0; i < n; i++)
11 				console_input(coninp[i], CONSOLE_STD);
12+			if (n == 0)
13+				console_input(0, CONSOLE_STD);
14 		}
15 	}
16 	return 1;