ref: b3ba8b3d7954b806299e324fd26d956feef5813a
parent: 5234a4333aad83ac5e188e22010b98c61a574f86
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Dec 7 09:29:45 EST 2020
libthread: reduce stack usage for ioprocs, open /proc/n/ctl with OCEXEC flag
--- a/sys/src/libthread/ioproc.c
+++ b/sys/src/libthread/ioproc.c
@@ -19,6 +19,15 @@
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 @@
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);
--
⑨