start: non-functional changes

parent d3d3fd0b
...@@ -257,35 +257,36 @@ restart: ...@@ -257,35 +257,36 @@ restart:
static int setup_signal_fd(sigset_t *oldmask) static int setup_signal_fd(sigset_t *oldmask)
{ {
int ret, sig;
sigset_t mask; sigset_t mask;
int fd; int signals[] = {SIGBUS, SIGILL, SIGSEGV, SIGWINCH};
/* Block everything except serious error signals. */ /* Block everything except serious error signals. */
if (sigfillset(&mask) || ret = sigfillset(&mask);
sigdelset(&mask, SIGILL) || if (ret < 0)
sigdelset(&mask, SIGSEGV) || return -EBADF;
sigdelset(&mask, SIGBUS) ||
sigdelset(&mask, SIGWINCH) || for (sig = 0; sig < (sizeof(signals) / sizeof(signals[0])); sig++) {
sigprocmask(SIG_BLOCK, &mask, oldmask)) { ret = sigdelset(&mask, signals[sig]);
SYSERROR("Failed to set signal mask."); if (ret < 0)
return -1; return -EBADF;
} }
fd = signalfd(-1, &mask, 0); ret = sigprocmask(SIG_BLOCK, &mask, oldmask);
if (fd < 0) { if (ret < 0) {
SYSERROR("Failed to create signal file descriptor."); SYSERROR("Failed to set signal mask");
return -1; return -EBADF;
} }
if (fcntl(fd, F_SETFD, FD_CLOEXEC)) { ret = signalfd(-1, &mask, SFD_CLOEXEC);
SYSERROR("Failed to set FD_CLOEXEC on the signal file descriptor: %d.", fd); if (ret < 0) {
close(fd); SYSERROR("Failed to create signal file descriptor");
return -1; return -EBADF;
} }
DEBUG("Set SIGCHLD handler with file descriptor: %d.", fd); TRACE("Created signal file descriptor %d", ret);
return fd; return ret;
} }
static int signal_handler(int fd, uint32_t events, void *data, static int signal_handler(int fd, uint32_t events, void *data,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment