i_free(node);
}
-static void sig_auth_cache_clear(int signo ATTR_UNUSED, void *context)
+static void sig_auth_cache_clear(const siginfo_t *si ATTR_UNUSED, void *context)
{
struct auth_cache *cache = context;
auth_cache_clear(cache);
}
-static void sig_auth_cache_stats(int signo ATTR_UNUSED, void *context)
+static void sig_auth_cache_stats(const siginfo_t *si ATTR_UNUSED, void *context)
{
struct auth_cache *cache = context;
unsigned int total_count;
static struct auth *auth;
static struct auth_worker_client *worker_client;
-static void sig_die(int signo, void *context ATTR_UNUSED)
+static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
{
/* warn about being killed because of some signal, except SIGINT (^C)
which is too common at least while testing :) */
- if (signo != SIGINT)
- i_warning("Killed with signal %d", signo);
+ if (si->si_signo != SIGINT)
+ i_warning("Killed with signal %d", si->si_signo);
io_loop_stop(ioloop);
}
winbind->pid = -1;
}
-static void sigchld_handler(int signo ATTR_UNUSED,
+static void sigchld_handler(const siginfo_t *si ATTR_UNUSED,
void *context ATTR_UNUSED)
{
winbind_wait_pid(&winbind_ntlm_context);
static ARRAY_DEFINE(lda_envs, const char *);
static ARRAY_DEFINE(plugin_envs, const char *);
-static void sig_die(int signo, void *context ATTR_UNUSED)
+static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
{
/* warn about being killed because of some signal, except SIGINT (^C)
which is too common at least while testing :) */
- if (signo != SIGINT)
- i_warning("Killed with signal %d", signo);
+ if (si->si_signo != SIGINT)
+ i_warning("Killed with signal %d", si->si_signo);
io_loop_stop(current_ioloop);
}
static struct module *modules;
static struct dict_server *dict_server;
-static void sig_die(int signo, void *context ATTR_UNUSED)
+static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
{
/* warn about being killed because of some signal, except SIGINT (^C)
which is too common at least while testing :) */
- if (signo != SIGINT)
- i_warning("Killed with signal %d", signo);
+ if (si->si_signo != SIGINT)
+ i_warning("Killed with signal %d", si->si_signo);
io_loop_stop(ioloop);
}
string_t *capability_string;
-static void sig_die(int signo, void *context ATTR_UNUSED)
+static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
{
/* warn about being killed because of some signal, except SIGINT (^C)
which is too common at least while testing :) */
- if (signo != SIGINT)
- i_warning("Killed with signal %d", signo);
+ if (si->si_signo != SIGINT)
+ i_warning("Killed with signal %d", si->si_signo);
io_loop_stop(ioloop);
}
}
static void
-sigchld_handler(int signo ATTR_UNUSED, void *context ATTR_UNUSED)
+sigchld_handler(const siginfo_t *si ATTR_UNUSED, void *context ATTR_UNUSED)
{
struct child_wait_status status;
static bool signals_initialized = FALSE;
static struct io *io_sig = NULL;
-static void sig_handler(int signo)
+static void sig_handler(int signo, siginfo_t *si, void *context ATTR_UNUSED)
{
struct signal_handler *h;
bool delayed_sent = FALSE;
called at any time. don't do anything that's unsafe. */
for (h = signal_handlers[signo]; h != NULL; h = h->next) {
if (!h->delayed)
- h->handler(signo, h->context);
+ h->handler(si, h->context);
else if (!delayed_sent) {
int saved_errno = errno;
- unsigned char signo_byte = signo;
- if (write(sig_pipe_fd[1], &signo_byte, 1) != 1)
+ if (write(sig_pipe_fd[1], si,
+ sizeof(*si)) != sizeof(*si))
i_error("write(sigpipe) failed: %m");
delayed_sent = TRUE;
errno = saved_errno;
}
}
-static void sig_ignore(int signo ATTR_UNUSED)
+static void sig_ignore(int signo ATTR_UNUSED, siginfo_t *si ATTR_UNUSED,
+ void *context ATTR_UNUSED)
{
/* if we used SIG_IGN instead of this function,
the system call might be restarted */
static void signal_read(void *context ATTR_UNUSED)
{
- unsigned char signal_buf[512];
- unsigned char signal_mask[MAX_SIGNAL_VALUE+1];
+ siginfo_t signal_buf[10];
+ siginfo_t signals[MAX_SIGNAL_VALUE+1];
ssize_t i, ret;
- unsigned int signo;
+ int signo;
ret = read(sig_pipe_fd[0], signal_buf, sizeof(signal_buf));
if (ret > 0) {
- memset(signal_mask, 0, sizeof(signal_mask));
+ if (ret % sizeof(siginfo_t) != 0)
+ i_fatal("read(sigpipe) returned partial data");
+ ret /= sizeof(siginfo_t);
- /* move them to mask first to avoid calling same handler
- multiple times */
+ /* get rid of duplicate signals */
+ memset(signals, 0, sizeof(signals));
for (i = 0; i < ret; i++) {
- signo = signal_buf[i];
+ signo = signal_buf[i].si_signo;
if (signo > MAX_SIGNAL_VALUE) {
i_panic("sigpipe contains signal %d > %d",
signo, MAX_SIGNAL_VALUE);
}
- signal_mask[signo] = 1;
+ signals[signo] = signal_buf[i];
}
/* call the delayed handlers */
for (signo = 0; signo < MAX_SIGNAL_VALUE; signo++) {
- if (signal_mask[signo] > 0) {
+ if (signals[signo].si_signo > 0) {
struct signal_handler *h =
signal_handlers[signo];
for (; h != NULL; h = h->next) {
- if (h->delayed)
- h->handler(signo, h->context);
+ if (h->delayed) {
+ h->handler(&signals[signo],
+ h->context);
+ }
}
}
}
if (sigemptyset(&act.sa_mask) < 0)
i_fatal("sigemptyset(): %m");
- act.sa_flags = 0;
- act.sa_handler = ignore ? sig_ignore : sig_handler;
+ act.sa_flags = SA_SIGINFO;
+ act.sa_sigaction = ignore ? sig_ignore : sig_handler;
if (sigaction(signo, &act, NULL) < 0)
i_fatal("sigaction(%d): %m", signo);
}
if (sigemptyset(&act.sa_mask) < 0)
i_fatal("sigemptyset(): %m");
- act.sa_flags = restart_syscalls ? SA_RESTART : 0;
- act.sa_handler = restart_syscalls ? SIG_IGN : sig_ignore;
+ if (restart_syscalls) {
+ act.sa_flags = SA_RESTART;
+ act.sa_handler = SIG_IGN;
+ } else {
+ act.sa_flags = SA_SIGINFO;
+ act.sa_sigaction = sig_ignore;
+ }
if (sigaction(signo, &act, NULL) < 0)
i_fatal("sigaction(%d): %m", signo);
#include <signal.h>
-typedef void signal_handler_t(int signo, void *context);
+typedef void signal_handler_t(const siginfo_t *si, void *context);
/* Set signal handler for specific signal. If delayed is TRUE, the handler
will be called later, ie. not as a real signal handler. */
}
}
-static void sig_die(int signo, void *context ATTR_UNUSED)
+static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
{
/* warn about being killed because of some signal, except SIGINT (^C)
which is too common at least while testing :) */
- if (signo != SIGINT)
- i_warning("Killed with signal %d", signo);
+ if (si->si_signo != SIGINT)
+ i_warning("Killed with signal %d", si->si_signo);
io_loop_stop(ioloop);
}
#endif
}
-static void sigchld_handler(int signo ATTR_UNUSED,
+static void sigchld_handler(const siginfo_t *si ATTR_UNUSED,
void *context ATTR_UNUSED)
{
struct child_process *process;
void child_processes_flush(void)
{
/* make sure we log if child processes died unexpectedly */
- sigchld_handler(SIGCHLD, NULL);
+ sigchld_handler(NULL, NULL);
}
void child_processes_deinit(void)
}
}
-static void sig_die(int signo, void *context ATTR_UNUSED)
+static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
{
/* warn about being killed because of some signal, except SIGINT (^C)
which is too common at least while testing :) */
- if (signo != SIGINT)
- i_warning("Killed with signal %d", signo);
+ if (si->si_signo != SIGINT)
+ i_warning("Killed with signal %d", si->si_signo);
io_loop_stop(ioloop);
}
-static void sig_reload_settings(int signo ATTR_UNUSED,
+static void sig_reload_settings(const siginfo_t *si ATTR_UNUSED,
void *context ATTR_UNUSED)
{
settings_reload();
}
-static void sig_reopen_logs(int signo ATTR_UNUSED,
+static void sig_reopen_logs(const siginfo_t *si ATTR_UNUSED,
void *context ATTR_UNUSED)
{
set_logfile(settings_root->defaults);
const char *uidl_format, *logout_format;
enum uidl_keys uidl_keymask;
-static void sig_die(int signo, void *context ATTR_UNUSED)
+static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
{
/* warn about being killed because of some signal, except SIGINT (^C)
which is too common at least while testing :) */
- if (signo != SIGINT)
- i_warning("Killed with signal %d", signo);
+ if (si->si_signo != SIGINT)
+ i_warning("Killed with signal %d", si->si_signo);
io_loop_stop(ioloop);
}
static struct ioloop *ioloop;
-static void sig_die(int signo ATTR_UNUSED, void *context ATTR_UNUSED)
+static void sig_die(const siginfo_t *si ATTR_UNUSED, void *context ATTR_UNUSED)
{
io_loop_stop(ioloop);
}