1010 * Copyright (c) 2004-2005 The Regents of the University of California.
1111 * All rights reserved.
1212 * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
13- * Copyright (c) 2016 Intel, Inc. All rights reserved.
13+ * Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
1414 * $COPYRIGHT$
1515 *
1616 * Additional copyrights may follow
@@ -244,10 +244,7 @@ orte_iof_base_setup_parent(const orte_process_name_t* name,
244244
245245int orte_iof_base_setup_output_files (const orte_process_name_t * dst_name ,
246246 orte_job_t * jobdat ,
247- orte_iof_proc_t * proct ,
248- orte_iof_sink_t * * stdoutsink ,
249- orte_iof_sink_t * * stderrsink ,
250- orte_iof_sink_t * * stddiagsink )
247+ orte_iof_proc_t * proct )
251248{
252249 int rc ;
253250 char * dirname , * outdir , * outfile ;
@@ -289,19 +286,15 @@ int orte_iof_base_setup_output_files(const orte_process_name_t* dst_name,
289286 } else {
290287 asprintf (& outdir , "%s/rank.%0*lu" , dirname ,
291288 numdigs , (unsigned long )proct -> name .vpid );
292-
293289 }
294290 /* ensure the directory exists */
295291 if (OPAL_SUCCESS != (rc = opal_os_dirpath_create (outdir , S_IRWXU |S_IRGRP |S_IXGRP ))) {
296292 ORTE_ERROR_LOG (rc );
297293 free (outdir );
298294 return rc ;
299295 }
300- /* if they asked for stderr to be combined with stdout, then we
301- * only create one file and tell the IOF to put both streams
302- * into it. Otherwise, we create separate files for each stream */
303- if (orte_get_attribute (& jobdat -> attributes , ORTE_JOB_MERGE_STDERR_STDOUT , NULL , OPAL_BOOL )) {
304- /* create the output file */
296+ if (NULL != proct -> revstdout && NULL == proct -> revstdout -> sink ) {
297+ /* setup the stdout sink */
305298 asprintf (& outfile , "%s/stdout" , outdir );
306299 fdout = open (outfile , O_CREAT |O_RDWR |O_TRUNC , 0644 );
307300 free (outfile );
@@ -311,40 +304,42 @@ int orte_iof_base_setup_output_files(const orte_process_name_t* dst_name,
311304 return ORTE_ERR_FILE_OPEN_FAILURE ;
312305 }
313306 /* define a sink to that file descriptor */
314- ORTE_IOF_SINK_DEFINE (stdoutsink , dst_name , fdout , ORTE_IOF_STDMERGE ,
315- orte_iof_base_write_handler );
316- /* point the stderr read event to it as well */
317- OBJ_RETAIN (* stdoutsink );
318- * stderrsink = * stdoutsink ;
319- } else {
320- /* create separate files for stderr and stdout */
321- asprintf (& outfile , "%s/stdout" , outdir );
322- fdout = open (outfile , O_CREAT |O_RDWR |O_TRUNC , 0644 );
323- free (outfile );
324- if (fdout < 0 ) {
325- /* couldn't be opened */
326- ORTE_ERROR_LOG (ORTE_ERR_FILE_OPEN_FAILURE );
327- return ORTE_ERR_FILE_OPEN_FAILURE ;
328- }
329- /* define a sink to that file descriptor */
330- ORTE_IOF_SINK_DEFINE (stdoutsink , dst_name , fdout , ORTE_IOF_STDOUT ,
307+ ORTE_IOF_SINK_DEFINE (& proct -> revstdout -> sink , dst_name ,
308+ proct -> revstdout -> fd , ORTE_IOF_STDOUT ,
331309 orte_iof_base_write_handler );
310+ }
332311
333- asprintf (& outfile , "%s/stderr" , outdir );
334- fdout = open (outfile , O_CREAT |O_RDWR |O_TRUNC , 0644 );
335- free (outfile );
336- if (fdout < 0 ) {
337- /* couldn't be opened */
338- ORTE_ERROR_LOG (ORTE_ERR_FILE_OPEN_FAILURE );
339- return ORTE_ERR_FILE_OPEN_FAILURE ;
312+ if (NULL != proct -> revstderr && NULL == proct -> revstderr -> sink ) {
313+ /* if they asked for stderr to be combined with stdout, then we
314+ * only create one file and tell the IOF to put both streams
315+ * into it. Otherwise, we create separate files for each stream */
316+ if (orte_get_attribute (& jobdat -> attributes , ORTE_JOB_MERGE_STDERR_STDOUT , NULL , OPAL_BOOL )) {
317+ /* just use the stdout sink */
318+ OBJ_RETAIN (proct -> revstdout -> sink );
319+ proct -> revstdout -> sink -> tag = ORTE_IOF_STDMERGE ; // show that it is merged
320+ proct -> revstderr -> sink = proct -> revstdout -> sink ;
321+ } else {
322+ asprintf (& outfile , "%s/stderr" , outdir );
323+ fdout = open (outfile , O_CREAT |O_RDWR |O_TRUNC , 0644 );
324+ free (outfile );
325+ if (fdout < 0 ) {
326+ /* couldn't be opened */
327+ ORTE_ERROR_LOG (ORTE_ERR_FILE_OPEN_FAILURE );
328+ return ORTE_ERR_FILE_OPEN_FAILURE ;
329+ }
330+ /* define a sink to that file descriptor */
331+ ORTE_IOF_SINK_DEFINE (& proct -> revstderr -> sink , dst_name ,
332+ proct -> revstderr -> fd , ORTE_IOF_STDERR ,
333+ orte_iof_base_write_handler );
340334 }
341- /* define a sink to that file descriptor */
342- ORTE_IOF_SINK_DEFINE (stderrsink , dst_name , fdout , ORTE_IOF_STDERR ,
343- orte_iof_base_write_handler );
344335 }
345- /* always tie the sink for stddiag to stderr */
346- OBJ_RETAIN (* stderrsink );
347- * stddiagsink = * stderrsink ;
336+
337+ if (NULL != proct -> revstddiag && NULL == proct -> revstddiag -> sink ) {
338+ /* always tie the sink for stddiag to stderr */
339+ OBJ_RETAIN (proct -> revstderr -> sink );
340+ proct -> revstddiag -> sink = proct -> revstderr -> sink ;
341+ }
348342 }
343+
349344 return ORTE_SUCCESS ;
350345}
0 commit comments