[sheepdog] [PATCH 7/7] logger: check sheep process after prctl is called

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Mon Oct 22 05:54:12 CEST 2012


The sheep process could exist before setting a signal handler, so we
need to check the aliveness of the process after prctl call.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 lib/logger.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/lib/logger.c b/lib/logger.c
index 12652c8..aa1c012 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -373,6 +373,11 @@ static notrace void logger(char *log_dir, char *outfile)
 
 	prctl(PR_SET_PDEATHSIG, SIGHUP);
 
+	/* we need to check the aliveness of the sheep process since
+	 * it could die before the logger call prctl. */
+	if (kill(sheep_pid, 0) < 0)
+		kill(logger_pid, SIGHUP);
+
 	while (la->active) {
 		log_flush();
 
-- 
1.7.2.5




More information about the sheepdog mailing list