25
25
#include "opal/mca/mca.h"
26
26
#include "opal/mca/base/base.h"
27
27
#include "opal/mca/base/mca_base_param.h"
28
#include "opal/util/os_dirpath.h"
29
#include "opal/util/basename.h"
29
31
#include "orte/util/show_help.h"
30
32
#include "orte/util/proc_info.h"
164
168
int orte_iof_base_open(void)
166
172
/* Initialize globals */
167
173
OBJ_CONSTRUCT(&orte_iof_base.iof_components_opened, opal_list_t);
168
174
OBJ_CONSTRUCT(&orte_iof_base.iof_write_output_lock, opal_mutex_t);
176
/* did the user request we print output to files? */
177
if (NULL != orte_output_filename) {
178
/* we will setup the files themselves as needed in the iof
179
* module. For now, let's see if the filename contains a
180
* path, or just a name
183
path = opal_dirname(orte_output_filename);
184
if (0 != strcmp(path, orte_output_filename)) {
185
/* there is a path in this name - ensure that the directory
186
* exists, and create it if not
188
if (ORTE_SUCCESS != (rc = opal_os_dirpath_create(path, S_IRWXU))) {
170
194
/* daemons do not need to do this as they do not write out stdout/err */
171
195
if (!orte_process_info.daemon) {
172
196
/* setup the stdout event */
173
OBJ_CONSTRUCT(&orte_iof_base.iof_write_stdout, orte_iof_write_event_t);
174
orte_iof_base.iof_write_stdout.fd = 1;
175
/* create the write event, but don't add it until we need it */
176
opal_event_set(&orte_iof_base.iof_write_stdout.ev,
177
orte_iof_base.iof_write_stdout.fd,
179
orte_iof_base_write_handler,
180
&orte_iof_base.iof_write_stdout);
197
ORTE_IOF_SINK_DEFINE(&orte_iof_base.iof_write_stdout, ORTE_PROC_MY_NAME,
198
1, ORTE_IOF_STDOUT, orte_iof_base_write_handler, NULL);
182
199
/* setup the stderr event */
183
OBJ_CONSTRUCT(&orte_iof_base.iof_write_stderr, orte_iof_write_event_t);
184
orte_iof_base.iof_write_stderr.fd = 2;
185
/* create the write event, but don't add it until we need it */
186
opal_event_set(&orte_iof_base.iof_write_stderr.ev,
187
orte_iof_base.iof_write_stderr.fd,
189
orte_iof_base_write_handler,
190
&orte_iof_base.iof_write_stderr);
200
ORTE_IOF_SINK_DEFINE(&orte_iof_base.iof_write_stderr, ORTE_PROC_MY_NAME,
201
2, ORTE_IOF_STDERR, orte_iof_base_write_handler, NULL);
191
202
/* do NOT set these file descriptors to non-blocking. If we do so,
192
203
* we set the file descriptor to non-blocking for everyone that has
193
204
* that file descriptor, which includes everyone else in our shell