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.
This commit is contained in:
parent
7761128093
commit
d7f90a9096
1 changed files with 8 additions and 9 deletions
|
@ -1111,14 +1111,7 @@ pexit(char *exitstr, int freemem)
|
||||||
* if not a kernel process and have a parent,
|
* if not a kernel process and have a parent,
|
||||||
* do some housekeeping.
|
* do some housekeeping.
|
||||||
*/
|
*/
|
||||||
if(up->kp == 0) {
|
if(up->kp == 0 && up->parentpid != 0) {
|
||||||
p = up->parent;
|
|
||||||
if(p == 0) {
|
|
||||||
if(exitstr == 0)
|
|
||||||
exitstr = "unknown";
|
|
||||||
panic("boot process died: %s", exitstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
wq = smalloc(sizeof(Waitq));
|
wq = smalloc(sizeof(Waitq));
|
||||||
wq->w.pid = up->pid;
|
wq->w.pid = up->pid;
|
||||||
utime = up->time[TUser] + up->time[TCUser];
|
utime = up->time[TUser] + up->time[TCUser];
|
||||||
|
@ -1131,11 +1124,12 @@ pexit(char *exitstr, int freemem)
|
||||||
else
|
else
|
||||||
wq->w.msg[0] = '\0';
|
wq->w.msg[0] = '\0';
|
||||||
|
|
||||||
|
p = up->parent;
|
||||||
lock(&p->exl);
|
lock(&p->exl);
|
||||||
/*
|
/*
|
||||||
* Check that parent is still alive.
|
* 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->nchild--;
|
||||||
p->time[TCUser] += utime;
|
p->time[TCUser] += utime;
|
||||||
p->time[TCSys] += stime;
|
p->time[TCSys] += stime;
|
||||||
|
@ -1158,6 +1152,11 @@ pexit(char *exitstr, int freemem)
|
||||||
if(wq)
|
if(wq)
|
||||||
free(wq);
|
free(wq);
|
||||||
}
|
}
|
||||||
|
else if(up->kp == 0 && up->parent == 0){
|
||||||
|
if(exitstr == 0)
|
||||||
|
exitstr = "unknown";
|
||||||
|
panic("boot process died: %s", exitstr);
|
||||||
|
}
|
||||||
|
|
||||||
if(!freemem)
|
if(!freemem)
|
||||||
addbroken(up);
|
addbroken(up);
|
||||||
|
|
Loading…
Reference in a new issue