code: plan9front

Download patch

ref: 58dc03cec0df3cf569f73ea90d71f17e6a3dc84d
parent: b48078c12cdf0e3b718e38102b7548c14bed33a4
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Jun 17 23:13:50 EDT 2015

kernel: do not inherit Proc.dot (current working directory) in kproc()

making sure to close the dot in every kproc appears repetitive,
so instead stop inheriting the dot in kproc() as this is usually
never what you wanted in the first place.

--- a/sys/src/9/port/proc.c
+++ b/sys/src/9/port/proc.c
@@ -1387,7 +1387,7 @@
 	p->s = up->s;
 	p->nerrlab = 0;
 	p->slash = up->slash;
-	p->dot = up->dot;
+	p->dot = up->slash;	/* unlike fork, do not inherit the dot for kprocs */
 	if(p->dot != nil)
 		incref(p->dot);
 
--- a/sys/src/9/port/segment.c
+++ b/sys/src/9/port/segment.c
@@ -837,10 +837,6 @@
 	incref(sio->s);
 	up->seg[sno] = sio->s;
 
-	cclose(up->dot);
-	up->dot = up->slash;
-	incref(up->dot);
-
 	while(waserror())
 		;
 	for(done = 0; !done;){
--- a/sys/src/9/port/swap.c
+++ b/sys/src/9/port/swap.c
@@ -149,10 +149,6 @@
 	Segment *s;
 	Proc *p, *ep;
 
-	cclose(up->dot);
-	up->dot = up->slash;
-	incref(up->dot);
-
 	p = proctab(0);
 	ep = &p[conf.nproc];
 
--- a/sys/src/9/zynq/screen.c
+++ b/sys/src/9/zynq/screen.c
@@ -116,10 +116,6 @@
 
 	up->seg[i] = arg;
 
-	cclose(up->dot);
-	up->dot = up->slash;
-	incref(up->dot);
-
 	hwcursor.proc = up;
 	if(waserror()){
 		hwcursor.addr = 0;
@@ -203,10 +199,6 @@
 		panic(up->text);
 
 	up->seg[sno] = arg;
-
-	cclose(up->dot);
-	up->dot = up->slash;
-	incref(up->dot);
 
 	fbscreen.proc = up;
 	if(waserror()){