コード例 #1
0
ファイル: sig.c プロジェクト: benatto/finit
/*
 * Shut down on INT USR1 USR2
 */
static void shutdown_handler(int sig, siginfo_t *info, void *UNUSED(ctx))
{
	_d("Rebooting on signal %d from %s (PID %d)",
	   sig, pid_get_name(info->si_pid, NULL, 0), info->si_pid);

	do_shutdown(sig);
}
コード例 #2
0
ファイル: sig.c プロジェクト: benatto/finit
static void sigcont_handler(int sig, siginfo_t *info, void *UNUSED(ctx))
{
	_d("Received SIGCONT(%d) from %s (PID %d)",
	   sig, pid_get_name(info->si_pid, NULL, 0), info->si_pid);
	stopped = 0;
	remove(SYNC_STOPPED);
}
コード例 #3
0
ファイル: sig.c プロジェクト: benatto/finit
/*
 * SIGSTOP: Paused by user or netflash
 */
static void sigstop_handler(int sig, siginfo_t *info, void *UNUSED(ctx))
{
	_d("Received SIGSTOP(%d) from %s (PID %d)",
	   sig, pid_get_name(info->si_pid, NULL, 0), info->si_pid);
	touch(SYNC_STOPPED);
	stopped ++;
}
コード例 #4
0
ファイル: service.c プロジェクト: rrogers96/finit
int service_stop(svc_t *svc)
{
	int res = 1;

	if (!svc)
		return 1;

	if (svc->pid <= 1) {
		_d("Bad PID %d for %s, SIGTERM", svc->pid, svc->desc);
		res = 1;
		goto exit;
	}

	if (SVC_TYPE_SERVICE != svc->type)
		return 0;

	if (runlevel != 1 && verbose)
		print_desc("Stopping ", svc->desc);

	_d("Sending SIGTERM to pid:%d name:%s", svc->pid, pid_get_name(svc->pid, NULL, 0));
	res = kill(svc->pid, SIGTERM);

	if (runlevel != 1 && verbose)
		print_result(res);
exit:
	svc->pid = 0;
	svc->restart_counter = 0;

	return res;
}
コード例 #5
0
ファイル: service.c プロジェクト: wkz/finit
int service_stop(svc_t *svc, int state)
{
	int res = 0;

	if (!svc)
		return 1;

	if (svc->pid <= 1) {
		_d("Bad PID %d for %s, SIGTERM", svc->pid, svc->desc);
		res = 1;
		goto exit;
	}

	if (SVC_TYPE_SERVICE != svc->type)
		return 0;

	_d("Service %s state %d, new state %d, sighup %d", svc->cmd, svc->state, state, svc->sighup);
	if (state == SVC_RELOAD_STATE && svc->sighup)
		goto exit;

	if (runlevel != 1 && verbose)
		print_desc("Stopping ", svc->desc);

	_d("Sending SIGTERM to pid:%d name:%s", svc->pid, pid_get_name(svc->pid, NULL, 0));
	res = kill(svc->pid, SIGTERM);

	if (runlevel != 1 && verbose)
		print_result(res);
exit:
	if (!res)
		svc->state = state;
	svc->restart_counter = 0;

	return res;
}
コード例 #6
0
ファイル: svc.c プロジェクト: cmatsuoka/finit
int svc_stop(svc_t *svc)
{
	int res = 1;

	if (!svc) {
		_e("Failed, no svc pointer.");
		return 1;
	}

	if (svc->pid <= 1) {
		_d("Bad PID %d for %s, SIGTERM", svc->pid, svc->desc);
		svc->pid = 0;
		svc->stat_restart_counter = 0;
		return 1;
	}

	if (runlevel != 1)
		print_desc("Stopping ", svc->desc);
	_d("Sending SIGTERM to pid:%d name:'%s'", svc->pid, pid_get_name(svc->pid, NULL, 0));
	res = kill(svc->pid, SIGTERM);
	if (runlevel != 1)
		print_result(res);
	svc->pid = 0;
	svc->stat_restart_counter = 0;

	return res;
}