summaryrefslogtreecommitdiff
path: root/sys/src/9/port/proc.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2013-12-07 08:25:26 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2013-12-07 08:25:26 +0100
commitd7f90a909637fcf12f564fa65b53a1416bef1f6c (patch)
tree879521e4808d63abe15fc973b08a563c7cd0d176 /sys/src/9/port/proc.c
parent77611280935dfbd7b976fd9340bf8593bf4320f1 (diff)
kernel: simplify pexit(), avoid making wait record for RFNOWAIT (parentless) procs
replaced the p->pid != 0 check with up->parentpid != 0 so p->pid == up->parentpid is never true for p->pid == 0. avoid allocating the wait records when up->parentpid == 0.
Diffstat (limited to 'sys/src/9/port/proc.c')
-rw-r--r--sys/src/9/port/proc.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sys/src/9/port/proc.c b/sys/src/9/port/proc.c
index ed549fb75..8f3817b57 100644
--- a/sys/src/9/port/proc.c
+++ b/sys/src/9/port/proc.c
@@ -1111,14 +1111,7 @@ pexit(char *exitstr, int freemem)
* if not a kernel process and have a parent,
* do some housekeeping.
*/
- if(up->kp == 0) {
- p = up->parent;
- if(p == 0) {
- if(exitstr == 0)
- exitstr = "unknown";
- panic("boot process died: %s", exitstr);
- }
-
+ if(up->kp == 0 && up->parentpid != 0) {
wq = smalloc(sizeof(Waitq));
wq->w.pid = up->pid;
utime = up->time[TUser] + up->time[TCUser];
@@ -1131,11 +1124,12 @@ pexit(char *exitstr, int freemem)
else
wq->w.msg[0] = '\0';
+ p = up->parent;
lock(&p->exl);
/*
* Check that parent is still alive.
*/
- if(p->pid != 0 && p->pid == up->parentpid && p->state != Broken) {
+ if(p->pid == up->parentpid && p->state != Broken) {
p->nchild--;
p->time[TCUser] += utime;
p->time[TCSys] += stime;
@@ -1158,6 +1152,11 @@ pexit(char *exitstr, int freemem)
if(wq)
free(wq);
}
+ else if(up->kp == 0 && up->parent == 0){
+ if(exitstr == 0)
+ exitstr = "unknown";
+ panic("boot process died: %s", exitstr);
+ }
if(!freemem)
addbroken(up);