Skip to contentSkip to conversation

wait4() WIFSTOPPED starvation fix #2/2

PATCH New David Howells 1 participant 1 message Mar 15, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wait4() WIFSTOPPED starvation fix #2/2

Hi Linus,

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.

David

kernel/exit.c renamed from kernel/exit.c-orig +6 -0
diff -uNr linux-256p1/kernel/exit.c-orig linux-wait-256p1/kernel/exit.c
@@ -592,6 +592,12 @@
 				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);
+				list_del(&p->sibling);
+				list_add_tail(&p->sibling,&p->parent->children);
+				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);