fix spurious kproc ppid

newproc() didnt zero parentpid and kproc() didnt set it, so
kprocs ended up with random parent pid. this is harmless as
kprocs have no up->parent but it gives confusing results in
pstree(1).

now we zero parentpid in newproc(), and set it in sysrfork()
unless RFNOWAIT has been set.
This commit is contained in:
cinap_lenrek 2012-11-07 20:46:30 +01:00
parent 479ea049e3
commit 6c8097a84d
2 changed files with 3 additions and 4 deletions

View file

@ -644,6 +644,7 @@ newproc(void)
p->nargs = 0;
p->setargs = 0;
memset(p->seg, 0, sizeof p->seg);
p->parentpid = 0;
p->noteid = pidalloc(p);
if(p->kstack == 0)
p->kstack = smalloc(KSTACK);

View file

@ -169,10 +169,8 @@ sysrfork(ulong *arg)
forkchild(p, up->dbgreg);
p->parent = up;
p->parentpid = up->pid;
if(flag&RFNOWAIT)
p->parentpid = 0;
else {
if((flag&RFNOWAIT) == 0){
p->parentpid = up->pid;
lock(&up->exl);
up->nchild++;
unlock(&up->exl);