From 7fde5e61bc7047433bfc1f47229b72d0ccd302e7 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Sun, 20 May 2012 16:34:27 +0200 Subject: Correected some nasty tasking bugs. Still not perfect. --- src/user/app/yosh/main.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/user/app/yosh') diff --git a/src/user/app/yosh/main.cpp b/src/user/app/yosh/main.cpp index fc9580c..160e728 100644 --- a/src/user/app/yosh/main.cpp +++ b/src/user/app/yosh/main.cpp @@ -167,8 +167,21 @@ int Main(String *sh_args) { } while (1) { - stdio.printf("\x1b[33m %s \x1b[1m", cwd.c_str()); + // check for background processes that may have finished + int p = 0; + while (p < bg_pr_c) { + int ret = libc::waitpid(bg_pr[p], 0); + if (ret != E_NOT_FINISHED) { + stdio.printf("(yosh) child (pid %i) exited with status %i\n", bg_pr[p], ret); + bg_pr_c--; + bg_pr[p] = bg_pr[bg_pr_c]; + } else { + p++; + } + } + // show prompt + stdio.printf("\x1b[33m %s \x1b[1m", cwd.c_str()); String s = term->readline(); stdio.printf("\x1b[0m"); if (s.size() == 0) continue; @@ -252,18 +265,6 @@ int Main(String *sh_args) { } } } - - int i = 0; - while (i < bg_pr_c) { - int ret = libc::waitpid(bg_pr[i], 0); - if (ret != E_NOT_FINISHED) { - stdio.printf("(yosh) child (pid %i) exited with status %i\n", bg_pr[i], ret); - bg_pr_c--; - bg_pr[i] = bg_pr[bg_pr_c]; - } else { - i++; - } - } } return 0; -- cgit v1.2.3