static int local_init(const char *option) { sigset_t mask; int ret; static struct timer t = { .callback = check_pids, .data = &t, }; if (option) shmfile = option; shm_queue_init(); sigemptyset(&mask); sigaddset(&mask, SIGUSR1); sigprocmask(SIG_BLOCK, &mask, NULL); sigfd = signalfd(-1, &mask, SFD_NONBLOCK); if (sigfd < 0) { sd_eprintf("failed to create a signal fd: %m"); return -1; } add_timer(&t, PROCESS_CHECK_INTERVAL); ret = register_event(sigfd, local_handler, NULL); if (ret) { sd_eprintf("failed to register local event handler (%d)", ret); return -1; } return 0; }
static int local_init(struct cdrv_handlers *handlers, const char *option, uint8_t *myaddr) { sigset_t mask; static struct timer t = { .callback = check_pids, .data = &t, }; lhdlrs = *handlers; if (option) shmfile = option; /* set 127.0.0.1 */ memset(myaddr, 0, 16); myaddr[12] = 127; myaddr[15] = 1; shm_queue_init(); sigemptyset(&mask); sigaddset(&mask, SIGUSR1); sigprocmask(SIG_BLOCK, &mask, NULL); sigfd = signalfd(-1, &mask, SFD_NONBLOCK); if (sigfd < 0) { eprintf("failed to create a signal fd: %m\n"); return -1; } add_timer(&t, 1); local_block_wq = init_work_queue(1); return sigfd; }