From 4fd55abb8e6dc11b257699cbd095fa5ef60e1ece Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 7 Dec 2013 05:38:31 +0100 Subject: kernel: fix pexit() Waitmsg memory leak. when a process got forked with RFNOWAIT, its p->parent will still point to the parent process, but its p->parentpid == 0. this causes the "parent still alive" check in pexit to get confused as it only checked p->pid == up->parentpid. this condition is *TRUE* in the case of RFNOWAIT when the parent process is actually dead (p->pid == 0) so we attached the wait structure to the dead parent leaking the memory. --- sys/src/9/port/proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/src/9/port/proc.c b/sys/src/9/port/proc.c index bbceff5ef..838ad49a1 100644 --- a/sys/src/9/port/proc.c +++ b/sys/src/9/port/proc.c @@ -1135,7 +1135,7 @@ pexit(char *exitstr, int freemem) /* * Check that parent is still alive. */ - if(p->pid == up->parentpid && p->state != Broken) { + if(p->pid != 0 && p->pid == up->parentpid && p->state != Broken) { p->nchild--; p->time[TCUser] += utime; p->time[TCSys] += stime; -- cgit v1.2.3