svn commit: r217307 - head/sbin/hastd

Pawel Jakub Dawidek pjd at FreeBSD.org
Wed Jan 12 14:35:30 UTC 2011


Author: pjd
Date: Wed Jan 12 14:35:29 2011
New Revision: 217307
URL: http://svn.freebsd.org/changeset/base/217307

Log:
  Install default signal handlers before masking signals we want to handle.
  It is possible that the parent process ignores some of them and sigtimedwait()
  will never see them, eventhough they are masked.
  
  The most common situation for this to happen is boot process where init(8)
  ignores SIGHUP before starting to execute /etc/rc. This in turn caused
  hastd(8) to ignore SIGHUP.
  
  Reported by:	trasz
  Obtained from:	Wheel Systems Sp. z o.o. http://www.wheelsystems.com
  MFC after:	3 days

Modified:
  head/sbin/hastd/hastd.c

Modified: head/sbin/hastd/hastd.c
==============================================================================
--- head/sbin/hastd/hastd.c	Wed Jan 12 14:13:50 2011	(r217306)
+++ head/sbin/hastd/hastd.c	Wed Jan 12 14:35:29 2011	(r217307)
@@ -754,10 +754,18 @@ main(int argc, char *argv[])
 	assert(cfg != NULL);
 
 	/*
+	 * Restore default actions for interesting signals in case parent
+	 * process (like init(8)) decided to ignore some of them (like SIGHUP).
+	 */
+	PJDLOG_VERIFY(signal(SIGHUP, SIG_DFL) != SIG_ERR);
+	PJDLOG_VERIFY(signal(SIGINT, SIG_DFL) != SIG_ERR);
+	PJDLOG_VERIFY(signal(SIGTERM, SIG_DFL) != SIG_ERR);
+	/*
 	 * Because SIGCHLD is ignored by default, setup dummy handler for it,
 	 * so we can mask it.
 	 */
 	PJDLOG_VERIFY(signal(SIGCHLD, dummy_sighandler) != SIG_ERR);
+
 	PJDLOG_VERIFY(sigemptyset(&mask) == 0);
 	PJDLOG_VERIFY(sigaddset(&mask, SIGHUP) == 0);
 	PJDLOG_VERIFY(sigaddset(&mask, SIGINT) == 0);


More information about the svn-src-head mailing list