#include <signal.h>
#include <unistd.h>
/**
* A custom handler is needed, SIG_IGN will not trigger pause().
*/
static void signal_handler(int sig) {
(void)sig; // unused
}
/**
* Ignore expected signals without restart to trigger EINTR without exit.
*/
static void register_handlers() {
struct sigaction sa = {0};
sigemptyset(&sa.sa_mask);
sa.sa_handler = &signal_handler;
sigaction(SIGHUP, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
sigaction(SIGQUIT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
}
/**
* Dummy utility daemon that waits for any signal indefinitely.
* Without any arguments or i/o. Success upon any expected signal.
*/
int main() {
close(0);
close(1);
close(2);
register_handlers();
(void)pause();
return 0;
}