/* Copyright (c) 2002-2018 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 *current_process_title;
#ifdef HAVE_SETPROCTITLE
#endif
#ifdef PROCTITLE_HACK
static char *process_title;
{
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 */
char **new_argv;
unsigned int i, count;
*memblock_r = memblock;
for (i = 0; i < count; i++) {
}
return new_argv;
}
{
/* OS X wants two NULs */
if (len < process_title_clean_pos) {
} else if (process_title_clean_pos != 0) {
}
}
#endif
{
#ifdef PROCTITLE_HACK
#endif
#ifdef HAVE_LIBBSD
#endif
process_name = (*argv)[0];
}
{
#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
/* 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
}