Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Jan 2011 14:35:30 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r217307 - head/sbin/hastd
Message-ID:  <201101121435.p0CEZUkM092038@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101121435.p0CEZUkM092038>