ref: d7f90a909637fcf12f564fa65b53a1416bef1f6c
parent: 77611280935dfbd7b976fd9340bf8593bf4320f1
author: cinap_lenrek <[email protected]>
date: Sat Dec 7 03:25:26 EST 2013
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.
--- a/sys/src/9/port/proc.c
+++ b/sys/src/9/port/proc.c
@@ -1111,14 +1111,7 @@
* 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 @@
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;
@@ -1157,6 +1151,11 @@
unlock(&p->exl);
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)