ref: 5234a4333aad83ac5e188e22010b98c61a574f86
parent: 39af6ce420677261171e39c384a5b8310b18ce62
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Dec 7 09:27:46 EST 2020
libthread: simplify threadsetname() - open /proc/n/args with OCEXEC flag - reduce stack usage by using smaller buffer for path - format pid as ulong
--- a/sys/src/libthread/id.c
+++ b/sys/src/libthread/id.c
@@ -59,7 +59,7 @@
threadsetname(char *fmt, ...)
{int fd;
- char buf[128];
+ char buf[32];
va_list arg;
Proc *p;
Thread *t;
@@ -72,8 +72,8 @@
t->cmdname = vsmprint(fmt, arg);
va_end(arg);
if(t->cmdname && p->nthreads == 1){- snprint(buf, sizeof buf, "#p/%lud/args", _tos->pid); //getpid());
- if((fd = open(buf, OWRITE)) >= 0){+ snprint(buf, sizeof buf, "/proc/%lud/args", (ulong)getpid());
+ if((fd = open(buf, OWRITE|OCEXEC)) >= 0){write(fd, t->cmdname, strlen(t->cmdname)+1);
close(fd);
}
--
⑨