terminal: fix exit behavior by monitoring shell process status

This commit is contained in:
boreddevnl 2026-05-13 21:15:13 +02:00
parent d4522cab21
commit 4f17e0787c

View file

@ -1235,10 +1235,22 @@ int main(void) {
for (int i = 0; i < g_tab_count; i++) {
TerminalSession *s = &g_tabs[i];
int read = 0;
// Read any remaining output from the TTY
while ((read = sys_tty_read_out(s->tty_id, out_buf, sizeof(out_buf))) > 0) {
session_process_output(s, out_buf, read);
if (i == g_active_tab) dirty = true;
}
/* Check if the shell process has exited
if it has, close the tab.*/
int status = 0;
if (sys_waitpid(s->bsh_pid, &status, 1) > 0) {
close_tab(i);
i--;
dirty = true;
continue;
}
}
while (ui_get_event(g_win, &ev)) {