]> err.no Git - systemd/commitdiff
util: try harder to rename the process
authorLennart Poettering <lennart@poettering.net>
Thu, 30 Jun 2011 02:16:10 +0000 (04:16 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 30 Jun 2011 02:16:10 +0000 (04:16 +0200)
src/main.c
src/util.c
src/util.h

index 045203383de7c55960b07ba158bb33f66ea98472..e10441c862d7766ea06890afd33113712ce6c1bc 100644 (file)
@@ -1033,6 +1033,8 @@ int main(int argc, char *argv[]) {
 
         program_invocation_short_name = systemd;
         prctl(PR_SET_NAME, systemd);
+        saved_argv = argv;
+        saved_argc = argc;
 
         log_show_color(isatty(STDERR_FILENO) > 0);
         log_show_location(false);
index a0c04e3204f81b259e4f84d0884338c6c30645be..270c7dac794abb0a423b1caf708fa5914fa4cac6 100644 (file)
@@ -64,6 +64,9 @@
 #include "exit-status.h"
 #include "hashmap.h"
 
+int saved_argc = 0;
+char **saved_argv = NULL;
+
 size_t page_size(void) {
         static __thread size_t pgsz = 0;
         long r;
@@ -3026,6 +3029,20 @@ void rename_process(const char name[8]) {
 
         if (program_invocation_name)
                 strncpy(program_invocation_name, name, strlen(program_invocation_name));
+
+        if (saved_argc > 0) {
+                int i;
+
+                if (saved_argv[0])
+                        strncpy(saved_argv[0], name, strlen(saved_argv[0]));
+
+                for (i = 1; i < saved_argc; i++) {
+                        if (!saved_argv[i])
+                                break;
+
+                        memset(saved_argv[i], 0, strlen(saved_argv[i]));
+                }
+        }
 }
 
 void sigset_add_many(sigset_t *ss, ...) {
index a26fb6f1777017e8bcbd9716d45de507dbeca4fb..083da2a545f8660ba4485f788f7a91549311aa0e 100644 (file)
@@ -477,4 +477,7 @@ int signal_from_string(const char *s);
 
 int signal_from_string_try_harder(const char *s);
 
+extern int saved_argc;
+extern char **saved_argv;
+
 #endif