shithub: riscv

Download patch

ref: 6c8097a84df72cc8819de64c0a79f895b784d6c8
parent: 479ea049e339ebcb94230384646e605aeb213ab8
author: cinap_lenrek <[email protected]>
date: Wed Nov 7 15:46:30 EST 2012

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.

--- a/sys/src/9/port/proc.c
+++ b/sys/src/9/port/proc.c
@@ -644,6 +644,7 @@
 	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);
--- a/sys/src/9/port/sysproc.c
+++ b/sys/src/9/port/sysproc.c
@@ -169,10 +169,8 @@
 	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);