]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add process_title_get()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 19 Sep 2017 10:49:03 +0000 (13:49 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Thu, 21 Sep 2017 12:17:34 +0000 (15:17 +0300)
src/lib/process-title.c
src/lib/process-title.h

index 0c5329b7d7c9d2111a95737fb7aa50d36266fb53..47644e9e0f90cb34816ad8b7cd8e9c05d7ffdcb5 100644 (file)
@@ -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);
 }
index 833a79eacead49f2c87cd2d4d5bfc5ab521f48c9..1e63b49349d58d09b05e82fdb2c27979b49c0eec 100644 (file)
@@ -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);