diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-06-30 04:16:10 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-06-30 04:16:10 +0200 |
commit | 9a0e68963464b6bc159cad53fd745491cd0b90f7 (patch) | |
tree | 0d01fd1938e514baa9c2a9ab1a0444efba2c59dc /src/util.c | |
parent | 7fbf31dfe3cb2f9619df28258208eba36922e9d3 (diff) |
util: try harder to rename the process
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index a0c04e3204..270c7dac79 100644 --- a/src/util.c +++ b/src/util.c @@ -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, ...) { |