]> git.lizzy.rs Git - plan9front.git/commitdiff
libthread: reduce stack usage for ioprocs, open /proc/n/ctl with OCEXEC flag
authorcinap_lenrek <cinap_lenrek@felloff.net>
Mon, 7 Dec 2020 13:29:45 +0000 (14:29 +0100)
committercinap_lenrek <cinap_lenrek@felloff.net>
Mon, 7 Dec 2020 13:29:45 +0000 (14:29 +0100)
sys/src/libthread/ioproc.c

index 32be310261b10401d0e6ff4faaa99dc0a7eb3a51..1ee56c4f32d5de83e43562823485ecd9891bdf9a 100644 (file)
@@ -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);