Skip to content

Commit 4dd9f89

Browse files
committed
Create an MCA parameter (ess_base_stream_buffering) that allows the user to override the system default for buffering of stdout/stderr streams. See 'man setvbuf' for more information.
Note: I am working on a system that buffered all output until the application fishished due to a default of 'fully buffered.' This makes debugging painful. This switch fixed the problem by allowing me to adjust the buffering. This commit was SVN r26119.
1 parent 4630c40 commit 4dd9f89

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

orte/mca/ess/base/base.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
1314
* $COPYRIGHT$
1415
*
1516
* Additional copyrights may follow
@@ -56,6 +57,11 @@ ORTE_DECLSPEC int orte_ess_base_close(void);
5657
*/
5758
ORTE_DECLSPEC extern int orte_ess_base_output;
5859

60+
/*
61+
* stdout/stderr buffering control parameter
62+
*/
63+
ORTE_DECLSPEC extern int orte_ess_base_std_buffering;
64+
5965
ORTE_DECLSPEC extern opal_list_t orte_ess_base_components_available;
6066

6167
#if ORTE_ENABLE_EPOCH

orte/mca/ess/base/ess_base_open.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
1314
* $COPYRIGHT$
1415
*
1516
* Additional copyrights may follow
@@ -51,10 +52,19 @@ orte_ess_base_module_t orte_ess = {
5152
NULL /* ft_event */
5253
};
5354
int orte_ess_base_output;
55+
int orte_ess_base_std_buffering = -1;
5456

5557
int
5658
orte_ess_base_open(void)
5759
{
60+
mca_base_param_reg_int_name("ess_base",
61+
"stream_buffering",
62+
"Adjust buffering for stdout/stderr "
63+
"[-1 system default] [0 unbuffered] [1 line buffered] [2 fully buffered] "
64+
"(Default: -1)",
65+
false, false,
66+
-1, &orte_ess_base_std_buffering);
67+
5868
orte_ess_base_output = opal_output_open(NULL);
5969

6070
OBJ_CONSTRUCT(&orte_ess_base_components_available, opal_list_t);

orte/mca/ess/base/ess_base_std_app.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved.
12+
* Copyright (c) 2010-2012 Oak Ridge National Labs. All rights reserved.
1313
* $COPYRIGHT$
1414
*
1515
* Additional copyrights may follow
@@ -65,6 +65,26 @@ int orte_ess_base_app_setup(void)
6565
int ret;
6666
char *error = NULL;
6767

68+
/*
69+
* stdout/stderr buffering
70+
* If the user requested to override the default setting then do
71+
* as they wish.
72+
*/
73+
if( orte_ess_base_std_buffering > -1 ) {
74+
if( 0 == orte_ess_base_std_buffering ) {
75+
setvbuf(stdout, NULL, _IONBF, 0);
76+
setvbuf(stderr, NULL, _IONBF, 0);
77+
}
78+
else if( 1 == orte_ess_base_std_buffering ) {
79+
setvbuf(stdout, NULL, _IOLBF, 0);
80+
setvbuf(stderr, NULL, _IOLBF, 0);
81+
}
82+
else if( 2 == orte_ess_base_std_buffering ) {
83+
setvbuf(stdout, NULL, _IOFBF, 0);
84+
setvbuf(stderr, NULL, _IOFBF, 0);
85+
}
86+
}
87+
6888
/* open the errmgr */
6989
if (ORTE_SUCCESS != (ret = orte_errmgr_base_open())) {
7090
ORTE_ERROR_LOG(ret);

0 commit comments

Comments
 (0)