Skip to content

Commit

Permalink
Merge pull request #5895 from trws/name-threads
Browse files Browse the repository at this point in the history
broker/module.c: name threads
  • Loading branch information
mergify[bot] committed Apr 17, 2024
2 parents a7d5bb5 + 92fd905 commit 21ce5c0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/broker/module.c
Expand Up @@ -91,6 +91,18 @@ static int setup_module_profiling (module_t *p)
cali_begin_int_byname ("flux.rank", p->rank);
cali_begin_string_byname ("flux.name", p->name);
#endif
size_t len = strlen (p->name);
// one character longer than target to pass -Wstringop-truncation
char local_name[17] = {0};
const char *name_ptr = p->name;
// pthread name is limited to 16 bytes including \0 on linux
if (len > 15) {
strncpy (local_name, p->name, 16);
local_name[15] = 0;
name_ptr = local_name;
}
// Set the name of each thread to its module name
(void) pthread_setname_np (pthread_self (), name_ptr);
return (0);
}

Expand Down

0 comments on commit 21ce5c0

Please sign in to comment.