summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-12-07 14:49:12 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2020-12-07 14:49:12 +0100
commitd570229e8268c96e97858f021b84bf00305f1daa (patch)
treee8a602b9fbc723087922587c5bdb9082d164f9d0
parentb3c9249500d1f6f2df42c1543c4deb87789510b5 (diff)
downloadplan9front-d570229e8268c96e97858f021b84bf00305f1daa.tar.xz
lib9p: improve reqqueuecreate()
- open /proc/n/ctl with OCEXEC flag - format pid as ulong - don't leak the fd
-rw-r--r--sys/src/lib9p/queue.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/src/lib9p/queue.c b/sys/src/lib9p/queue.c
index 478f40ddd..ff846cfd8 100644
--- a/sys/src/lib9p/queue.c
+++ b/sys/src/lib9p/queue.c
@@ -16,8 +16,8 @@ _reqqueueproc(void *v)
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 @@ _reqqueueproc(void *v)
f(r);
}
+ if(fd >= 0)
+ close(fd);
free(r);
free(q);
threadexits(nil);