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:
cinap_lenrek 2013-12-07 08:25:26 +01:00
parent 7761128093
commit d7f90a9096

View file

@ -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);