Commit 37e0a7a0 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(server_init): Handle SIGTERM and SIGINT the same way as SIGHUP: shut down.

(main): Ditto.
(sighandler_term): New name for former sighandler_hup.  Log proper
	message depending on which signal was used to shut down the
parent a42f69fc
* $Id: ramkomd.c,v 0.125 2003/08/04 06:54:18 ceder Exp $
* $Id: ramkomd.c,v 0.126 2003/08/12 13:14:14 ceder Exp $
* Copyright (C) 1991-1999, 2001-2002 Lysator Academic Computer Association.
* This file is part of the LysKOM server.
......@@ -133,7 +133,7 @@ static oop_adapter_signal *kom_signal_adapter;
static void dump_exit_statistics(void);
static void free_kom_info(void);
static oop_call_signal sighandler_hup;
static oop_call_signal sighandler_term;
static oop_call_signal sighandler_quit;
static oop_call_signal sighandler_usr1;
static oop_call_signal sighandler_usr2;
......@@ -192,18 +192,22 @@ server_init(const char *host, const char * client_port)
way, when liboop reinstalls the old signal handler during
shutdown, we will ignore them rather than stop prematurely
during the shutdown. This is especially important for the
SIGHUP signal, which is sent periodically by updateLysKOM. */
SIGTERM signal, which is sent periodically by updateLysKOM. */
act.sa_flags = 0;
sigaction(SIGHUP, &act, NULL);
sigaction(SIGTERM, &act, NULL);
sigaction(SIGINT, &act, NULL);
sigaction(SIGQUIT, &act, NULL);
sigaction(SIGUSR1, &act, NULL);
sigaction(SIGUSR2, &act, NULL);
sigaction(SIGWINCH, &act, NULL);
signal(SIGHUP, SIG_IGN);
signal(SIGINT, SIG_IGN);
signal(SIGUSR1, SIG_IGN);
signal(SIGUSR2, SIG_IGN);
......@@ -212,7 +216,9 @@ server_init(const char *host, const char * client_port)
src = oop_signal_source(kom_signal_adapter);
src->on_signal(src, SIGHUP, sighandler_hup, NULL);
src->on_signal(src, SIGHUP, sighandler_term, NULL);
src->on_signal(src, SIGTERM, sighandler_term, NULL);
src->on_signal(src, SIGINT, sighandler_term, NULL);
src->on_signal(src, SIGQUIT, sighandler_quit, NULL);
src->on_signal(src, SIGUSR1, sighandler_usr1, NULL);
src->on_signal(src, SIGUSR2, sighandler_usr2, NULL);
......@@ -274,11 +280,22 @@ init_data_base(void)
static void *
sighandler_hup(oop_source *UNUSED(source),
int UNUSED(sig),
sighandler_term(oop_source *UNUSED(source),
int sig,
void *UNUSED(user))
kom_log ("Signal HUP received. Shutting down server.\n");
if (sig == SIGTERM)
kom_log("Signal TERM received. Shutting down server.\n");
else if (sig == SIGHUP)
kom_log("Signal HUP received. Shutting down server."
" Please use SIGTERM instead.\n");
else if (sig == SIGINT)
kom_log("Signal INT received. Shutting down server."
" Please use SIGTERM instead.\n");
kom_log("Some signal received. Shutting down server."
" Please use SIGTERM instead.\n");
go_and_die = TRUE;
return OOP_HALT;
......@@ -647,7 +664,9 @@ main (int argc,
src->cancel_signal(src, SIGUSR2, sighandler_usr2, NULL);
src->cancel_signal(src, SIGUSR1, sighandler_usr1, NULL);
src->cancel_signal(src, SIGQUIT, sighandler_quit, NULL);
src->cancel_signal(src, SIGHUP, sighandler_hup, NULL);
src->cancel_signal(src, SIGHUP, sighandler_term, NULL);
src->cancel_signal(src, SIGTERM, sighandler_term, NULL);
src->cancel_signal(src, SIGINT, sighandler_term, NULL);
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