Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=9e528cda909d18026aae484958e07303d7cdf0d9 Commit: 9e528cda909d18026aae484958e07303d7cdf0d9 Parent: beb2da8139a20d81af6bb1e11a6de66838cf0c90 Author: Christine Caulfield <ccaulfie@redhat.com> AuthorDate: Thu Jul 30 12:39:06 2009 +0100 Committer: Christine Caulfield <ccaulfie@redhat.com> CommitterDate: Thu Jul 30 12:39:06 2009 +0100 cman: Enable error reporting from config modules The closure of stderr has been moved from cman_tool into cman-preconfig, this means that any errors reported to stderr by (eg) libXML will appear on the console when cman starts up. Signed-off-by: Christine Caulfield <ccaulfie@redhat.com> --- cman/cman_tool/join.c | 17 ++++++----------- cman/daemon/cman-preconfig.c | 6 ++++++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cman/cman_tool/join.c b/cman/cman_tool/join.c index 2a0e017..78c400e 100644 --- a/cman/cman_tool/join.c +++ b/cman/cman_tool/join.c @@ -10,7 +10,7 @@ static char *argv[MAX_ARGS]; static char *envp[MAX_ARGS]; -static void be_daemon(int close_stderr) +static void be_daemon(void) { int devnull = open("/dev/null", O_RDWR); if (devnull == -1) { @@ -27,15 +27,10 @@ static void be_daemon(int close_stderr) die("Error setting terminal FDs to /dev/null: %m"); } - if (close_stderr) { - if (close(2)) { - die("Error closing stderr FD"); - } - if (!dup2(devnull, 2) < 0) { - die("Error setting stderr FD to /dev/null: %m"); - } - } - + /* We leave stderr open to allow error messags through. + the cman plugin will close it when it's all started + up properly. + */ setsid(); } @@ -226,7 +221,7 @@ int join(commandline_t *comline, char *main_envp[]) fprintf(stderr, "%s\n", envp[i]); } } - be_daemon(!(comline->verbose & ~DEBUG_STARTUP_ONLY)); + be_daemon(); sprintf(scratch, "FORKED: %d\n", getpid()); err = write(p[1], scratch, strlen(scratch)); diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c index 8c490df..4cdd00d 100644 --- a/cman/daemon/cman-preconfig.c +++ b/cman/daemon/cman-preconfig.c @@ -1232,6 +1232,12 @@ 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 + */ + if (!debug) + close(STDERR_FILENO); return ret; }