New siginfo member in uev_t for signal watchers

This patch adds support for exporting the signalfd_siginfo struct read
from the signal fd descriptor on signals.  This allows watcher callbacks
to, e.g., figure out who sent a signal.  See signalfd(2) for details on
struct signalfd_siginfo.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-05-18 09:57:57 +02:00
1 parent bfd8454a92
commit e20d37228d
4 files changed
+14 -2

No files matched your search

+7 -1
View File
@@ -67,14 +67,20 @@ static int callback(arg_t *arg, int event, void *foo)
static void sigsegv_cb(uev_t *w, void *arg, int events)
{
printf("Got SIGSEGV (%d) from PID %d\n", w->siginfo.ssi_signo,
w->siginfo.ssi_pid);
warnx("PID %d caused segfault.", getpid());
exit(-1);
}
static void sigchld_cb(uev_t *w, void *arg, int events)
{
pid_t pid = waitpid(-1, NULL, WNOHANG);
pid_t pid;
printf("Got SIGCHLD (%d) from PID %d\n",
w->siginfo.ssi_signo, w->siginfo.ssi_pid);
pid = waitpid(-1, NULL, WNOHANG);
if (-1 != pid)
warnx("PID %d exited, bye.", pid);
}