From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21950 invoked by alias); 21 Aug 2009 13:09:42 -0000 Received: (qmail 21944 invoked by alias); 21 Aug 2009 13:09:42 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: STABLE3 - cman: Assign stderr to /dev/null rather than closing it To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE3 X-Git-Reftype: branch X-Git-Oldrev: d91b912aedfe0b44a8fba970d4a670fba3607fec X-Git-Newrev: 495d7fcd5e75a3591ca32708e4d05b44a1573d36 From: Christine Caulfield Message-Id: <20090821130916.678F11201A2@lists.fedorahosted.org> Date: Fri, 21 Aug 2009 13:09:00 -0000 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00232.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=495d7fcd5e75a3591ca32708e4d05b44a1573d36 Commit: 495d7fcd5e75a3591ca32708e4d05b44a1573d36 Parent: d91b912aedfe0b44a8fba970d4a670fba3607fec Author: Christine Caulfield AuthorDate: Fri Aug 21 14:07:50 2009 +0100 Committer: Christine Caulfield 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 --- 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 #include #include +#include #define SYSLOG_NAMES #include #include @@ -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; }