public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: Christine Caulfield <chrissie@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: cluster: STABLE3 - cman: Assign stderr to /dev/null rather than closing it
Date: Fri, 21 Aug 2009 13:09:00 -0000	[thread overview]
Message-ID: <20090821130916.678F11201A2@lists.fedorahosted.org> (raw)

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;
 }
 


                 reply	other threads:[~2009-08-21 13:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090821130916.678F11201A2@lists.fedorahosted.org \
    --to=chrissie@fedoraproject.org \
    --cc=cluster-cvs-relay@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).