From d220f2cb3c2ef28d9ebbc1020abbe8ee8a629ff4 Mon Sep 17 00:00:00 2001 From: Quentin Armitage Date: Sun, 29 Nov 2015 09:54:13 +0000 Subject: Set thread conditions before adding to list It seems safer to set the status and type of a thread before adding it to the ready list. Signed-off-by: Quentin Armitage (cherry picked from commit bf91d428e67b63f6584f7d98438ee2947775d838) --- lib/scheduler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/scheduler.c b/lib/scheduler.c index ce35d4b..eed824d 100644 --- a/lib/scheduler.c +++ b/lib/scheduler.c @@ -719,7 +719,7 @@ thread_child_handler(void * v, int sig) */ thread_t *thread; pid_t pid; - int status = 77; + int status; while ((pid = waitpid(-1, &status, WNOHANG))) { if (pid == -1) { if (errno == ECHILD) @@ -734,9 +734,9 @@ thread_child_handler(void * v, int sig) thread = t->next; if (pid == t->u.c.pid) { thread_list_delete(&m->child, t); - thread_list_add(&m->ready, t); t->u.c.status = status; t->type = THREAD_READY; + thread_list_add(&m->ready, t); break; } } -- 1.7.12.1