aboutsummaryrefslogtreecommitdiff
path: root/sig.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2006-11-01 21:10:56 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2006-11-01 21:10:56 +0000
commit225d5fe945bb6fc6d7a523b5944e96243a6b5038 (patch)
treed5c5a5cd7161344d514dbdd50bee42db4d50e376 /sig.c
parentauth-pam change: link with -lpam rather (diff)
downloadopenvpn-225d5fe945bb6fc6d7a523b5944e96243a6b5038.tar.xz
Prevent SIGUSR1 or SIGHUP from causing program
exit from initial management hold. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@1427 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'sig.c')
-rw-r--r--sig.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/sig.c b/sig.c
index 7eb120e..9d8756b 100644
--- a/sig.c
+++ b/sig.c
@@ -202,13 +202,23 @@ signal_handler_exit (const int signum)
#endif
+/* set handlers for unix signals */
+
+#ifdef HAVE_SIGNAL_H
+#define SM_UNDEF 0
+#define SM_PRE_INIT 1
+#define SM_POST_INIT 2
+static int signal_mode; /* GLOBAL */
+#endif
+
void
pre_init_signal_catch (void)
{
#ifdef HAVE_SIGNAL_H
+ signal_mode = SM_PRE_INIT;
signal (SIGINT, signal_handler);
signal (SIGTERM, signal_handler);
- signal (SIGHUP, signal_handler);
+ signal (SIGHUP, SIG_IGN);
signal (SIGUSR1, SIG_IGN);
signal (SIGUSR2, SIG_IGN);
signal (SIGPIPE, SIG_IGN);
@@ -219,6 +229,7 @@ void
post_init_signal_catch (void)
{
#ifdef HAVE_SIGNAL_H
+ signal_mode = SM_POST_INIT;
signal (SIGINT, signal_handler);
signal (SIGTERM, signal_handler);
signal (SIGHUP, signal_handler);
@@ -228,6 +239,18 @@ post_init_signal_catch (void)
#endif /* HAVE_SIGNAL_H */
}
+/* called after daemonization to retain signal settings */
+void
+restore_signal_state (void)
+{
+#ifdef HAVE_SIGNAL_H
+ if (signal_mode == SM_PRE_INIT)
+ pre_init_signal_catch ();
+ else if (signal_mode == SM_POST_INIT)
+ post_init_signal_catch ();
+#endif
+}
+
/*
* Print statistics.
*