add set_threadname function

This commit is contained in:
Stefan Seyfried
2013-10-05 22:01:57 +02:00
parent 642de31a8b
commit 3ed147cab7
2 changed files with 13 additions and 0 deletions

View File

@@ -3,6 +3,10 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/prctl.h>
#include <string.h>
int cnxt_debug = 0; /* compat, unused */
@@ -76,3 +80,11 @@ void lt_debug_init(void)
fprintf(stderr, "\n");
}
}
void hal_set_threadname(const char *name)
{
char threadname[17];
strncpy(threadname, name, sizeof(threadname));
threadname[16] = 0;
prctl (PR_SET_NAME, (unsigned long)&threadname);
}

View File

@@ -23,6 +23,7 @@
extern int debuglevel;
void hal_set_threadname(const char *name);
void _lt_debug(int facility, const void *, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
void _lt_info(int facility, const void *, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
void lt_debug_init(void);