Skip to content

Commit

Permalink
Fix #51: Catching SIGSEGV not needed anymore
Browse files Browse the repository at this point in the history
This patch fixes issue #51 by reverting b4b63d3, which is not needed
anymore since service callbacks have been removed from Finit3.

The `sig_unblock()` function, called for each forked off child, should
now be balanced with caught signals.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
  • Loading branch information
troglobit committed Nov 27, 2016
1 parent b9ae4d0 commit 829ff0b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
2 changes: 1 addition & 1 deletion service.c
Expand Up @@ -185,7 +185,7 @@ static int service_start(svc_t *svc)
/* Declare we're waiting for svc to create its pidfile */
svc_starting(svc);

/* Block sigchild while forking. */
/* Block SIGCHLD while forking. */
sigemptyset(&nmask);
sigaddset(&nmask, SIGCHLD);
sigprocmask(SIG_BLOCK, &nmask, &omask);
Expand Down
14 changes: 1 addition & 13 deletions sig.c
Expand Up @@ -90,7 +90,7 @@ shutop_t halt = SHUT_DEFAULT;
static int stopped = 0;
static uev_t sigterm_watcher, sigusr1_watcher, sigusr2_watcher;
static uev_t sighup_watcher, sigint_watcher, sigpwr_watcher;
static uev_t sigchld_watcher, sigsegv_watcher;
static uev_t sigchld_watcher;
static uev_t sigstop_watcher, sigtstp_watcher, sigcont_watcher;

void mdadm_wait(void);
Expand Down Expand Up @@ -281,15 +281,6 @@ static void sigchld_cb(uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events))
} while (pid > 0);
}

/*
* SIGSEGV: mostly if service callbacks segfault
*/
static void sigsegv_cb(uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events))
{
_e("PID %d caused a segfault!\n", getpid());
exit(-1);
}

/*
* SIGSTOP/SIGTSTP: Paused by user or netflash
*/
Expand Down Expand Up @@ -393,9 +384,6 @@ void sig_setup(uev_ctx_t *ctx)
/* After initial bootstrap of Finit we call the service monitor to reap children */
uev_signal_init(ctx, &sigchld_watcher, sigchld_cb, NULL, SIGCHLD);

/* Trap SIGSEGV in case service callbacks crash */
uev_signal_init(ctx, &sigsegv_watcher, sigsegv_cb, NULL, SIGSEGV);

/* Stopping init is a bit tricky. */
uev_signal_init(ctx, &sigstop_watcher, sigstop_cb, NULL, SIGSTOP);
uev_signal_init(ctx, &sigtstp_watcher, sigstop_cb, NULL, SIGTSTP);
Expand Down

0 comments on commit 829ff0b

Please sign in to comment.