lib9p: improve reqqueuecreate()

- open /proc/n/ctl with OCEXEC flag
- format pid as ulong
- don't leak the fd
This commit is contained in:
cinap_lenrek 2020-12-07 14:49:12 +01:00
parent b3c9249500
commit d570229e82

View file

@ -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);