public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - cman: Assign stderr to /dev/null rather than closing it
@ 2009-08-21 13:09 Christine Caulfield
  0 siblings, 0 replies; only message in thread
From: Christine Caulfield @ 2009-08-21 13:09 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=495d7fcd5e75a3591ca32708e4d05b44a1573d36
Commit:        495d7fcd5e75a3591ca32708e4d05b44a1573d36
Parent:        d91b912aedfe0b44a8fba970d4a670fba3607fec
Author:        Christine Caulfield <ccaulfie@redhat.com>
AuthorDate:    Fri Aug 21 14:07:50 2009 +0100
Committer:     Christine Caulfield <ccaulfie@redhat.com>
CommitterDate: Fri Aug 21 14:07:50 2009 +0100

cman: Assign stderr to /dev/null rather than closing it

If stderr is closed then it can be re-opened as another file
which can then get log messages. In some cases this can result
in all messages being duplicated in /var/log/cluster/corosync.log

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
---
 cman/daemon/cman-preconfig.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
index f813ac7..aece9a5 100644
--- a/cman/daemon/cman-preconfig.c
+++ b/cman/daemon/cman-preconfig.c
@@ -9,6 +9,7 @@
 #include <sys/socket.h>
 #include <sys/errno.h>
 #include <netdb.h>
+#include <fcntl.h>
 #define SYSLOG_NAMES
 #include <sys/syslog.h>
 #include <ifaddrs.h>
@@ -1314,11 +1315,19 @@ static int cmanpre_readconfig(struct objdb_iface_ver0 *objdb, const char **error
         *error_string = error_reason;
 
 
-	/* Close stderr, because cman_tool tells corosync not to.
-	   This helps pass error messages back to the command-line
+	/* nullify stderr, because cman_tool tells corosync not to.
+	   This helps pass error messages back to the command-line, when
+	   debug is enabled.
 	*/
-	if (!debug)
-	    close(STDERR_FILENO);
+	if (!debug) {
+		int tmpfd;
+		tmpfd = open("/dev/null", O_RDWR);
+		if (tmpfd > -1 && tmpfd != STDERR_FILENO) {
+			dup2(tmpfd, STDERR_FILENO);
+			close(tmpfd);
+		}
+
+	}
 	return ret;
 }
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-08-21 13:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-21 13:09 cluster: STABLE3 - cman: Assign stderr to /dev/null rather than closing it Christine Caulfield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).