process-title.c revision 5a35caefcf8cf38c347f8406b26701487c8cda57
/* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "env-util.h"
#include "process-title.h"
#ifdef HAVE_LIBBSD
#else
#include <unistd.h> /* FreeBSD */
#endif
static char *process_name = NULL;
static char *current_process_title;
#ifdef HAVE_SETPROCTITLE
#endif
#ifdef PROCTITLE_HACK
#define PROCTITLE_CLEAR_CHAR 0xab
static char *process_title;
static void *argv_memblock, *environ_memblock;
{
char *last;
unsigned int i;
bool clear_env;
/* find the last argv or environment string. it should always be the
last string in environ, but don't rely on it. this is what openssh
does, so hopefully it's safe enough. */
}
else {
}
}
process_title = argv[0];
/* if there are problems with this approach, try to make sure we
notice it */
if (clear_env) {
} else {
}
}
{
/* @UNSAFE */
void *memblock, *memblock_end;
char **new_argv;
unsigned int i, count;
*memblock_r = memblock;
for (i = 0; i < count; i++) {
}
return new_argv;
}
static void proctitle_hack_set(const char *title)
{
/* OS X wants two NULs */
if (len < process_title_clean_pos) {
} else if (process_title_clean_pos != 0) {
}
}
#endif
{
#ifdef PROCTITLE_HACK
char ***environ_p = env_get_environ_p();
char **orig_environ = *environ_p;
#endif
#ifdef HAVE_LIBBSD
#endif
process_name = (*argv)[0];
}
void process_title_set(const char *title)
{
#ifdef HAVE_SETPROCTITLE
else
#elif defined(PROCTITLE_HACK)
T_BEGIN {
} T_END;
#endif
}
const char *process_title_get(void)
{
return current_process_title;
}
void process_title_deinit(void)
{
#ifdef PROCTITLE_HACK
char ***environ_p = env_get_environ_p();
/* Environment is no longer usable. Make sure we won't crash in case
some library's deinit function still calls getenv(). This code was
mainly added because of GNUTLS where we don't really care about the
getenv() call.
Alternatively we could remove the free() calls above, but that would
annoy memory leak checking tools. Also we could attempt to restore
the environ_p to its original state, but that's a bit complicated. */
#endif
}