]> git.hungrycats.org Git - linux/commitdiff
[PATCH] wait4() WIFSTOPPED starvation fix #2/2
authorDavid Howells <dhowells@redhat.com>
Fri, 15 Mar 2002 06:39:17 +0000 (22:39 -0800)
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Fri, 15 Mar 2002 06:39:17 +0000 (22:39 -0800)
This patch actually fixes the starvation bug in sys_wait4() by moving any
process which is serviced for stoppage to the end of the child list.

kernel/exit.c

index ac0bd045fb10f157c377cdf1995f4cc19d8afc1f..d2cba1fc65d567770c360132f90c684bfc9560fd 100644 (file)
@@ -592,6 +592,12 @@ repeat:
                                if (!(options & WUNTRACED) && !(p->ptrace & PT_PTRACED))
                                        continue;
                                read_unlock(&tasklist_lock);
+
+                               /* move to end of parent's list to avoid starvation */
+                               write_lock_irq(&tasklist_lock);
+                               remove_parent(p);
+                               add_parent(p, p->parent);
+                               write_unlock_irq(&tasklist_lock);
                                retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0; 
                                if (!retval && stat_addr) 
                                        retval = put_user((p->exit_code << 8) | 0x7f, stat_addr);