]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2006-09-13 20:04:57 by entropy]
authorentropy <entropy@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 13 Sep 2006 20:04:57 +0000 (20:04 +0000)
committerentropy <entropy@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 13 Sep 2006 20:04:57 +0000 (20:04 +0000)
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

lcd4linux.c
thread.c
thread.h

index 1e33e7cef371b3c87f228e4a21d15feebe543e8f..824c59cda8880d1e3df86b38032c7bcb644490b3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: lcd4linux.c,v 1.81 2006/08/13 06:46:51 reinelt Exp $
+/* $Id: lcd4linux.c,v 1.82 2006/09/13 20:04:57 entropy Exp $
  *
  * LCD4Linux
  *
@@ -23,6 +23,9 @@
  *
  *
  * $Log: lcd4linux.c,v $
+ * Revision 1.82  2006/09/13 20:04:57  entropy
+ * threads change argv[0] to their thread name, for a neat 'ps' output
+ *
  * Revision 1.81  2006/08/13 06:46:51  reinelt
  * T6963 soft-timing & enhancements; indent
  *
 #include "timer.h"
 #include "layout.h"
 #include "plugin.h"
+#include "thread.h"
 
 #include "widget.h"
 #include "widget_timer.h"
@@ -541,6 +545,10 @@ int main(int argc, char *argv[])
        my_argv[c] = strdup(argv[c]);
     }
     my_argv[c] = NULL;
+   
+    /* save original arguments pointer for threads */
+    thread_argv=argv;
+    thread_argc=argc;
 
     running_foreground = 0;
     running_background = 0;
index bbfad14801bec6a29a730f87f00bdad22abecd79..2aac1280aa1790f58041a56fe80968ec93e6623e 100644 (file)
--- 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
  *
 #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);
index fcecc89ca7f8a604a2c9b875a20805c475c18d77..39ef6a815f4027356b8fa7a41cead64bb80335e3 100644 (file)
--- a/thread.h
+++ b/thread.h
@@ -1,4 +1,4 @@
-/* $Id: thread.h,v 1.7 2006/07/12 21:01:41 reinelt Exp $
+/* $Id: thread.h,v 1.8 2006/09/13 20:04:57 entropy Exp $
  *
  * thread handling (mutex, shmem, ...)
  *
@@ -26,6 +26,9 @@
  *
  *
  * $Log: thread.h,v $
+ * Revision 1.8  2006/09/13 20:04:57  entropy
+ * threads change argv[0] to their thread name, for a neat 'ps' output
+ *
  * Revision 1.7  2006/07/12 21:01:41  reinelt
  * thread_destroy, minor cleanups
  *
 #ifndef _THREAD_H_
 #define _THREAD_H_
 
+
+extern int   thread_argc;
+extern char **thread_argv;
+
 int mutex_create(void);
 void mutex_lock(const int semid);
 void mutex_unlock(const int semid);