shithub: riscv

Download patch

ref: d570229e8268c96e97858f021b84bf00305f1daa
parent: b3c9249500d1f6f2df42c1543c4deb87789510b5
author: cinap_lenrek <[email protected]>
date: Mon Dec 7 09:49:12 EST 2020

lib9p: improve reqqueuecreate()

- open /proc/n/ctl with OCEXEC flag
- format pid as ulong
- don't leak the fd

--- a/sys/src/lib9p/queue.c
+++ b/sys/src/lib9p/queue.c
@@ -16,8 +16,8 @@
 	q = v;
 	rfork(RFNOTEG);
 
-	buf = smprint("/proc/%d/ctl", getpid());
-	fd = open(buf, OWRITE);
+	buf = smprint("/proc/%lud/ctl", (ulong)getpid());
+	fd = open(buf, OWRITE|OCEXEC);
 	free(buf);
 	
 	for(;;){
@@ -40,6 +40,8 @@
 		f(r);
 	}
 
+	if(fd >= 0)
+		close(fd);
 	free(r);
 	free(q);
 	threadexits(nil);