aboutsummaryrefslogtreecommitdiffstats
path: root/thread.c
diff options
context:
space:
mode:
authorentropy <entropy@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2006-09-13 20:04:57 +0000
committerentropy <entropy@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2006-09-13 20:04:57 +0000
commitb416e414376c0eeb472e93a41b394085e94df7b2 (patch)
tree0b49417dff00d4abb990be01669342dc7afcb26a /thread.c
parent663f8445f1120cbb21653da3956f0e35be881ebe (diff)
downloadlcd4linux-b416e414376c0eeb472e93a41b394085e94df7b2.tar.gz
[lcd4linux @ 2006-09-13 20:04:57 by entropy]
threads change argv[0] to their thread name, for a neat 'ps' output git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@711 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/thread.c b/thread.c
index bbfad14..2aac128 100644
--- a/thread.c
+++ b/thread.c
@@ -1,4 +1,4 @@
-/* $Id: thread.c,v 1.8 2006/07/12 21:01:41 reinelt Exp $
+/* $Id: thread.c,v 1.9 2006/09/13 20:04:57 entropy Exp $
*
* thread handling (mutex, shmem, ...)
*
@@ -26,6 +26,9 @@
*
*
* $Log: thread.c,v $
+ * Revision 1.9 2006/09/13 20:04:57 entropy
+ * threads change argv[0] to their thread name, for a neat 'ps' output
+ *
* Revision 1.8 2006/07/12 21:01:41 reinelt
* thread_destroy, minor cleanups
*
@@ -108,6 +111,10 @@
#endif
+int thread_argc;
+char **thread_argv;
+
+
/* glibc 2.1 requires defining semun ourselves */
#ifdef _SEM_SEMUN_UNDEFINED
union semun {
@@ -195,13 +202,16 @@ int thread_create(const char *name, void (*thread) (void *data), void *data)
pid_t pid, ppid;
ppid = getpid();
-
+
switch (pid = fork()) {
case -1:
error("fatal error: fork(%s) failed: %s", name, strerror(errno));
return -1;
case 0:
info("thread %s starting...", name);
+ if (thread_argc > 0) {
+ strncpy(thread_argv[0],name,strlen(thread_argv[0]));
+ }
thread(data);
info("thread %s ended.", name);
exit(0);