From 49d2932d3005cc823cfa1fb4459e90ba438eda12 Mon Sep 17 00:00:00 2001 From: Gerd von Egidy Date: Tue, 29 Apr 2014 22:37:42 +0200 Subject: [PATCH] Fix how the stdin/stdout fds are set to null during Daemonize(). Fixes #5951 Signed-off-by: Gunnar Beutner --- icinga-app/icinga.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 8c7940ca1..0b9f4d0ca 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -149,14 +149,14 @@ static bool Daemonize(const String& stderrFile) exit(0); int fdnull = open("/dev/null", O_RDWR); - if (fdnull > 0) { + if (fdnull >= 0) { if (fdnull != 0) dup2(fdnull, 0); if (fdnull != 1) dup2(fdnull, 1); - if (fdnull > 2) + if (fdnull > 1) close(fdnull); }