From: Timo Sirainen Date: Tue, 19 Sep 2017 10:49:03 +0000 (+0300) Subject: lib: Add process_title_get() X-Git-Tag: 2.3.0.rc1~971 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5a35caefcf8cf38c347f8406b26701487c8cda57;p=thirdparty%2Fdovecot%2Fcore.git lib: Add process_title_get() --- diff --git a/src/lib/process-title.c b/src/lib/process-title.c index 0c5329b7d7..47644e9e0f 100644 --- a/src/lib/process-title.c +++ b/src/lib/process-title.c @@ -11,6 +11,7 @@ #endif static char *process_name = NULL; +static char *current_process_title; #ifdef HAVE_SETPROCTITLE # undef PROCTITLE_HACK @@ -135,10 +136,12 @@ void process_title_init(int argc ATTR_UNUSED, char **argv[]) process_name = (*argv)[0]; } -void process_title_set(const char *title ATTR_UNUSED) +void process_title_set(const char *title) { i_assert(process_name != NULL); + i_free(current_process_title); + current_process_title = i_strdup(title); #ifdef HAVE_SETPROCTITLE if (title == NULL) setproctitle(NULL); @@ -151,6 +154,11 @@ void process_title_set(const char *title ATTR_UNUSED) #endif } +const char *process_title_get(void) +{ + return current_process_title; +} + void process_title_deinit(void) { #ifdef PROCTITLE_HACK @@ -169,4 +177,5 @@ void process_title_deinit(void) the environ_p to its original state, but that's a bit complicated. */ *environ_p = NULL; #endif + i_free(current_process_title); } diff --git a/src/lib/process-title.h b/src/lib/process-title.h index 833a79eace..1e63b49349 100644 --- a/src/lib/process-title.h +++ b/src/lib/process-title.h @@ -6,6 +6,10 @@ void process_title_init(int argc, char **argv[]); /* Change the process title if possible. */ void process_title_set(const char *title); +/* Return the previously set process title. NULL means that it's either not + set, or the title was explicitly set to NULL previously. */ +const char *process_title_get(void); + /* Free all memory used by process title hacks. This should be the last function called by the process, since it frees argv and environment. */ void process_title_deinit(void);