Beispiel #1
0
/*
 * Setup limited set of SysV compatible signals to respond to
 */
void sig_setup(uev_ctx_t *ctx)
{
	struct sigaction sa;

	_d("Setup signals");

	/* Cleanup any stale finit control files */
	erase(SYNC_SHUTDOWN);
	erase(SYNC_STOPPED);

	/* Standard SysV init calls ctrl-alt-delete handler */
	uev_signal_init(ctx, &sigint_watcher, sigint_cb, NULL, SIGINT);
	uev_signal_init(ctx, &sigpwr_watcher, sigint_cb, NULL, SIGPWR);

	/* BusyBox init style signals for halt, power-off and reboot. */
	uev_signal_init(ctx, &sigusr1_watcher, sigusr1_cb, NULL, SIGUSR1);
	uev_signal_init(ctx, &sigusr2_watcher, sigusr2_cb, NULL, SIGUSR2);
	uev_signal_init(ctx, &sigterm_watcher, sigterm_cb, NULL, SIGTERM);

	/* Some C APIs may need SIGALRM for implementing timers. */
	IGNSIG(sa, SIGALRM, 0);

	/* /etc/inittab not supported yet, instead /etc/finit.d/ is scanned for *.conf */
	uev_signal_init(ctx, &sighup_watcher, sighup_cb, NULL, SIGHUP);

	/* After initial bootstrap of Finit we call the service monitor to reap children */
	uev_signal_init(ctx, &sigchld_watcher, sigchld_cb, NULL, SIGCHLD);

	/* 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);
	uev_signal_init(ctx, &sigcont_watcher, sigcont_cb, NULL, SIGCONT);

	setsid();
}
Beispiel #2
0
static void setup_signals(uev_ctx_t *ctx)
{
	/* Signals to stop watchdogd */
	uev_signal_init(ctx, &sigterm_watcher, exit_cb, NULL, SIGTERM);
	uev_signal_init(ctx, &sigint_watcher,  exit_cb, NULL, SIGINT);
	uev_signal_init(ctx, &sigquit_watcher, exit_cb, NULL, SIGQUIT);

	/* Watchdog reboot support */
	uev_signal_init(ctx, &sigpwr_watcher, reboot_cb, NULL, SIGPWR);
}
Beispiel #3
0
/*
 * Setup limited set of SysV compatible signals to respond to
 */
void sig_setup(uev_ctx_t *ctx)
{
	struct sigaction sa;

	_d("Setup signals");

	/* Cleanup any stale finit control files */
	erase(SYNC_SHUTDOWN);
	erase(SYNC_STOPPED);

	/* Standard SysV init calls ctrl-alt-delete handler */
	uev_signal_init(ctx, &sigint_watcher, sigint_cb, NULL, SIGINT);
	uev_signal_init(ctx, &sigpwr_watcher, sigint_cb, NULL, SIGPWR);

	/* Ignore SIGUSR1/2 for now, only BusyBox init implements them as reboot+halt. */
//	uev_signal_init(&ctx, &sigusr1_watcher, reopen_initctl_cb, NULL, SIGUSR1);
//	uev_signal_init(&ctx, &sigusr2_watcher, pwrdwn_cb, NULL, SIGUSR2);

	/* Init must ignore SIGTERM. May otherwise get false SIGTERM in forked children! */
	IGNSIG(sa, SIGTERM, 0);

	/* Some C APIs may need SIGALRM for implementing timers. */
	IGNSIG(sa, SIGALRM, 0);

	/* We don't have any /etc/inittab yet, reread finit.conf? */
	IGNSIG(sa, SIGHUP, 0);

	/* 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);
	uev_signal_init(ctx, &sigcont_watcher, sigcont_cb, NULL, SIGCONT);

	/* Disable CTRL-ALT-DELETE from kernel, we handle shutdown gracefully with SIGINT, above */
	reboot(RB_DISABLE_CAD);
	setsid();
}