#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>static void sghdl(int sig, siginfo_t *sgf, void *vodi __attribute__((unused))) {
printf("PID: %d SIG: %d\n", sgf->si_pid, sig);
}
int main(void) {
struct sigaction sa;
int i;
memset((void *)&sa, 0, sizeof(struct sigaction));
sa.sa_sigaction = (void *)&sghdl;
sa.sa_flags = SA_SIGINFO;
for (i = 1; i < NSIG; i++) {
if (i == SIGKILL || i == SIGSEGV || i == SIGSTOP)
continue;
sigaction(i, &sa, NULL);
}
sleep(24 * 60 * 60);
return 0;
}