diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-12-07 14:49:12 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-12-07 14:49:12 +0100 |
commit | d570229e8268c96e97858f021b84bf00305f1daa (patch) | |
tree | e8a602b9fbc723087922587c5bdb9082d164f9d0 | |
parent | b3c9249500d1f6f2df42c1543c4deb87789510b5 (diff) | |
download | plan9front-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.c | 6 |
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); |