diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-12-07 14:29:45 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-12-07 14:29:45 +0100 |
commit | e45bd6814a125e7a175ff19e23252608a060d847 (patch) | |
tree | 65d3c6512c390fdadfa827772b8aab47e6815c84 | |
parent | 1e2657ee9726e5dd9b8b1f39fa94bb02c1f5cdb7 (diff) | |
download | plan9front-e45bd6814a125e7a175ff19e23252608a060d847.tar.xz |
libthread: reduce stack usage for ioprocs, open /proc/n/ctl with OCEXEC flag
-rw-r--r-- | sys/src/libthread/ioproc.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/src/libthread/ioproc.c b/sys/src/libthread/ioproc.c index 32be31026..1ee56c4f3 100644 --- a/sys/src/libthread/ioproc.c +++ b/sys/src/libthread/ioproc.c @@ -19,6 +19,15 @@ iointerrupt(Ioproc *io) qunlock(io); } +static int +openprocctl(void) +{ + char buf[32]; + + snprint(buf, sizeof(buf), "/proc/%lud/ctl", (ulong)getpid()); + return open(buf, OWRITE|OCEXEC); +} + static void xioproc(void *a) { @@ -28,15 +37,11 @@ xioproc(void *a) c = a; if(io = mallocz(sizeof(*io), 1)){ - char buf[128]; - /* * open might fail, ignore it for programs like factotum * that don't use iointerrupt() anyway. */ - snprint(buf, sizeof(buf), "/proc/%d/ctl", getpid()); - io->ctl = open(buf, OWRITE); - + io->ctl = openprocctl(); if((io->creply = chancreate(sizeof(void*), 0)) == nil){ if(io->ctl >= 0) close(io->ctl); |