summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-12-07 14:27:46 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2020-12-07 14:27:46 +0100
commit1e2657ee9726e5dd9b8b1f39fa94bb02c1f5cdb7 (patch)
tree91d89f9fca7d55dcf63c5aadcfcd0dd1cecac5d0
parentf1e15da8f550b12196d57e245437251f6eb289b5 (diff)
downloadplan9front-1e2657ee9726e5dd9b8b1f39fa94bb02c1f5cdb7.tar.xz
libthread: simplify threadsetname()
- open /proc/n/args with OCEXEC flag - reduce stack usage by using smaller buffer for path - format pid as ulong
-rw-r--r--sys/src/libthread/id.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/src/libthread/id.c b/sys/src/libthread/id.c
index 22d60f423..289dc8698 100644
--- a/sys/src/libthread/id.c
+++ b/sys/src/libthread/id.c
@@ -59,7 +59,7 @@ void
threadsetname(char *fmt, ...)
{
int fd;
- char buf[128];
+ char buf[32];
va_list arg;
Proc *p;
Thread *t;
@@ -72,8 +72,8 @@ threadsetname(char *fmt, ...)
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);
}