setrlimit(RLIMIT_STACK, &rlim);
if (cf->bind_conf) {
- setproctitle("%s process (%s)", cf->worker->name,
- cf->bind_conf->bind_line);
+ rspamd_setproctitle("%s process (%s)", cf->worker->name,
+ cf->bind_conf->bind_line);
}
else {
- setproctitle("%s process", cf->worker->name);
+ rspamd_setproctitle("%s process", cf->worker->name);
}
if (rspamd_main->pfh) {
static gchar *title_buffer = NULL;
static size_t title_buffer_size = 0;
static gchar *title_progname, *title_progname_full;
-#endif
-#ifdef LINUX
static void
rspamd_title_dtor(gpointer d)
{
g_free(env);
}
-#endif
+#endif /* ifdef LINUX */
+
+#endif /* ifndef HAVE_SETPROCTITLE */
-gint init_title(rspamd_mempool_t *pool,
- gint argc, gchar *argv[], gchar *envp[])
+gint rspamd_init_title(rspamd_mempool_t *pool,
+ gint argc, gchar *argv[], gchar *envp[])
{
-#ifdef LINUX
+#if defined(LINUX) && !defined(HAVE_SETPROCTITLE)
gchar *begin_of_buffer = 0, *end_of_buffer = 0;
gint i;
return 0;
}
-gint setproctitle(const gchar *fmt, ...)
+gint rspamd_setproctitle(const gchar *fmt, ...)
{
+#ifdef HAVE_SETPROCTITLE
+ if (fmt) {
+ static char titlebuf[4096];
+ va_list ap;
+
+ va_start(ap, fmt);
+ rspamd_vsnprintf(titlebuf, sizeof(titlebuf), fmt, ap);
+ va_end(ap);
+
+ setproctitle("%s", titlebuf);
+ }
+#else
#if defined(LINUX)
if (!title_buffer || !title_buffer_size) {
errno = ENOMEM;
g_set_prgname(dest->str);
g_string_free(dest, TRUE);
-#endif
+#endif /* defined(LINUX) */
+
+#endif /* HAVE_SETPROCTITLE */
return 0;
}
-#endif
#ifndef HAVE_PIDFILE
static gint _rspamd_pidfile_remove(rspamd_pidfh_t *pfh, gint freeit);
void rspamd_signals_init(struct sigaction *sa, void (*sig_handler)(gint));
#endif
-#ifndef HAVE_SETPROCTITLE
-
/*
* Process title utility functions
*/
-gint init_title(rspamd_mempool_t *pool, gint argc, gchar *argv[], gchar *envp[]);
-
-gint setproctitle(const gchar *fmt, ...);
-
-#endif
+gint rspamd_init_title(rspamd_mempool_t *pool, gint argc, gchar *argv[], gchar *envp[]);
+gint rspamd_setproctitle(const gchar *fmt, ...);
#ifndef HAVE_PIDFILE
/*
-/*-
- * Copyright 2019 Vsevolod Stakhov
+/*
+ * Copyright 2023 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
ev_loop_destroy(cbdata->event_loop);
if (proctitle) {
- setproctitle("lua process: %s", proctitle);
+ rspamd_setproctitle("lua process: %s", proctitle);
}
else {
- setproctitle("lua process: unnamed");
+ rspamd_setproctitle("lua process: unnamed");
}
cbdata->event_loop = ev_loop_new(EVFLAG_SIGNALFD);
cfg->compiled_modules = modules;
cfg->compiled_workers = workers;
- setproctitle("rspamdadm");
+ rspamd_setproctitle("rspamdadm");
L = cfg->lua_state;
rspamd_lua_set_path(L, NULL, ucl_vars);
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2023 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
(new_spam - old_spam) / w->repeat,
(new_ham - old_ham) / w->repeat,
cnt > 0 ? sum / cnt : 0);
- setproctitle("%s", proctitle);
+ rspamd_setproctitle("%s", proctitle);
}
memcpy(&old_stat, &cur_stat, sizeof(cur_stat));
}
#ifndef HAVE_SETPROCTITLE
- init_title(rspamd_main->server_pool, argc, argv, env);
+ rspamd_init_title(rspamd_main->server_pool, argc, argv, env);
#endif
rspamd_main->cfg->libs_ctx = rspamd_init_libs();
sigprocmask(SIG_BLOCK, &signals.sa_mask, NULL);
/* Set title */
- setproctitle("main process");
+ rspamd_setproctitle("main process");
/* Open control socket if needed */
control_fd = -1;