add set_threadname function

Origin commit data
------------------
Branch: master
Commit: 3ed147cab7
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2013-10-05 (Sat, 05 Oct 2013)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
Stefan Seyfried
2013-10-05 22:01:57 +02:00
parent 8eba568def
commit a99d5454e8
2 changed files with 13 additions and 0 deletions

View File

@@ -3,6 +3,10 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h>
#include <sys/prctl.h>
#include <string.h>
int cnxt_debug = 0; /* compat, unused */ int cnxt_debug = 0; /* compat, unused */
@@ -76,3 +80,11 @@ void lt_debug_init(void)
fprintf(stderr, "\n"); 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; 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_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_info(int facility, const void *, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
void lt_debug_init(void); void lt_debug_init(void);