commit a1ec136
uint
·
2026-07-31 18:52:17 +0000 UTC
parent 55b6cc3
exit on shell close
1 files changed,
+13,
-1
+13,
-1
1@@ -8,6 +8,7 @@
2 #include <stdlib.h>
3 #include <string.h>
4 #include <sys/ioctl.h>
5+#include <sys/wait.h>
6 #include <time.h>
7 #ifdef __linux__
8 #include <pty.h>
9@@ -34,6 +35,7 @@ static void resize_pty(void);
10 static int resize_window(int w, int h);
11 static void resize_terminal(int w, int h);
12 static void run(void);
13+static bool shell_exited(void);
14 static void wait_events(void);
15
16 static Fontface font;
17@@ -299,7 +301,7 @@ static void run(void)
18
19 while (running) {
20 while (maus_event_poll(win, &ev)) {
21- if (ev.type == MAUS_EV_CLOSE) {
22+ if (ev.type == MAUS_EV_CLOSE || shell_exited()) {
23 running = false;
24 break;
25 }
26@@ -392,6 +394,16 @@ static void run(void)
27 }
28 }
29
30+/* check if the shell has exited */
31+static bool shell_exited(void)
32+{
33+ int status;
34+
35+ if (term.ptypid <= 0)
36+ return true;
37+ return waitpid(term.ptypid, &status, WNOHANG) == term.ptypid;
38+}
39+
40 /* wait for activity while allowing window events */
41 static void wait_events(void)
42 {