From 2c91ac861a7637259d018c0e02e0c02c075e3e3c Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 17 Feb 2006 15:06:08 +0000 Subject: [PATCH] When not in debug mode, tie stdout/stderr to dev null so we don't see messages from orted (i.e., from the srun command). This commit was SVN r9083. --- orte/mca/pls/slurm/pls_slurm_module.c | 35 ++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/orte/mca/pls/slurm/pls_slurm_module.c b/orte/mca/pls/slurm/pls_slurm_module.c index cff6c09eb5..64f55c2577 100644 --- a/orte/mca/pls/slurm/pls_slurm_module.c +++ b/orte/mca/pls/slurm/pls_slurm_module.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana + * Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. * Copyright (c) 2004-2005 The University of Tennessee and The University @@ -25,8 +25,22 @@ #include "orte_config.h" #include +#ifdef HAVE_UNISTD_H #include +#endif #include +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif #include "opal/util/argv.h" #include "opal/util/output.h" @@ -434,6 +448,7 @@ static int pls_slurm_finalize(void) static int pls_slurm_start_proc(int argc, char **argv, char **env, char *prefix) { + int fd; char *exec_argv = opal_path_findv(argv[0], 0, env, NULL); if (NULL == exec_argv) { @@ -481,8 +496,22 @@ static int pls_slurm_start_proc(int argc, char **argv, char **env, free(newenv); } - /* JMS -- when not in debug mode, tie stdout/stderr to dev - null so we don't see messages from orted */ + /* When not in debug mode, tie stdout/stderr to dev null so we + don't see messages from orted */ + if (!mca_pls_slurm_component.debug) { + fd = open("/dev/null", O_CREAT|O_WRONLY|O_TRUNC, 0666); + if (fd >= 0) { + if (fd != 1) { + dup2(fd,1); + } + if (fd != 2) { + dup2(fd,2); + } + if (fd > 2) { + close(fd); + } + } + } /* get the srun process out of orterun's process group so that signals sent from the shell (like those resulting from