diff --git a/orte/mca/ess/base/base.h b/orte/mca/ess/base/base.h index 1fb0c22d12..4047423d80 100644 --- a/orte/mca/ess/base/base.h +++ b/orte/mca/ess/base/base.h @@ -10,6 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2012 Oak Ridge National Labs. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -56,6 +57,11 @@ ORTE_DECLSPEC int orte_ess_base_close(void); */ ORTE_DECLSPEC extern int orte_ess_base_output; +/* + * stdout/stderr buffering control parameter + */ +ORTE_DECLSPEC extern int orte_ess_base_std_buffering; + ORTE_DECLSPEC extern opal_list_t orte_ess_base_components_available; #if ORTE_ENABLE_EPOCH diff --git a/orte/mca/ess/base/ess_base_open.c b/orte/mca/ess/base/ess_base_open.c index 608aba9807..8bf42512bf 100644 --- a/orte/mca/ess/base/ess_base_open.c +++ b/orte/mca/ess/base/ess_base_open.c @@ -10,6 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2012 Oak Ridge National Labs. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -51,10 +52,19 @@ orte_ess_base_module_t orte_ess = { NULL /* ft_event */ }; int orte_ess_base_output; +int orte_ess_base_std_buffering = -1; int orte_ess_base_open(void) { + mca_base_param_reg_int_name("ess_base", + "stream_buffering", + "Adjust buffering for stdout/stderr " + "[-1 system default] [0 unbuffered] [1 line buffered] [2 fully buffered] " + "(Default: -1)", + false, false, + -1, &orte_ess_base_std_buffering); + orte_ess_base_output = opal_output_open(NULL); OBJ_CONSTRUCT(&orte_ess_base_components_available, opal_list_t); diff --git a/orte/mca/ess/base/ess_base_std_app.c b/orte/mca/ess/base/ess_base_std_app.c index 2dd2b9ffc0..9063e99e30 100644 --- a/orte/mca/ess/base/ess_base_std_app.c +++ b/orte/mca/ess/base/ess_base_std_app.c @@ -9,7 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved. + * Copyright (c) 2010-2012 Oak Ridge National Labs. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -65,6 +65,26 @@ int orte_ess_base_app_setup(void) int ret; char *error = NULL; + /* + * stdout/stderr buffering + * If the user requested to override the default setting then do + * as they wish. + */ + if( orte_ess_base_std_buffering > -1 ) { + if( 0 == orte_ess_base_std_buffering ) { + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); + } + else if( 1 == orte_ess_base_std_buffering ) { + setvbuf(stdout, NULL, _IOLBF, 0); + setvbuf(stderr, NULL, _IOLBF, 0); + } + else if( 2 == orte_ess_base_std_buffering ) { + setvbuf(stdout, NULL, _IOFBF, 0); + setvbuf(stderr, NULL, _IOFBF, 0); + } + } + /* open the errmgr */ if (ORTE_SUCCESS != (ret = orte_errmgr_base_open())) { ORTE_ERROR_LOG(ret);