mirror of
https://github.com/BoredDevNL/BoredOS.git
synced 2026-05-15 10:48:38 +00:00
terminal: fix exit behavior by monitoring shell process status
This commit is contained in:
parent
d4522cab21
commit
4f17e0787c
1 changed files with 12 additions and 0 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue