Skip to content

Commit f5280c9

Browse files
committed
Adding changes for issue #6303 for branch v3.0.x.
Signed-off-by: Jason Williams <[email protected]> Adding changes for issue #6303 for branch master. Signed-off-by: Jason Williams <[email protected]> (cherry picked from commit 98d81a5) Conflicts: orte/mca/odls/pspawn/odls_pspawn.c
1 parent 87b7e56 commit f5280c9

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

orte/mca/odls/alps/odls_alps_module.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,15 @@ static int close_open_file_descriptors(int write_fd,
298298
return ORTE_ERR_FILE_OPEN_FAILURE;
299299
}
300300
struct dirent *files;
301+
302+
/* grab the fd of the opendir above so we don't close in the
303+
* middle of the scan. */
304+
int dir_scan_fd = dirfd(dir);
305+
if(dir_scan_fd < 0 ) {
306+
return ORTE_ERR_FILE_OPEN_FAILURE;
307+
}
308+
309+
301310
while (NULL != (files = readdir(dir))) {
302311
if (!isdigit(files->d_name[0])) {
303312
continue;
@@ -311,7 +320,8 @@ static int close_open_file_descriptors(int write_fd,
311320
#if OPAL_PMIX_V1
312321
fd != opts.p_internal[1] &&
313322
#endif
314-
fd != write_fd) {
323+
fd != write_fd &&
324+
fd != dir_scan_fd) {
315325
close(fd);
316326
}
317327
}

orte/mca/odls/default/odls_default_module.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,15 @@ static int close_open_file_descriptors(int write_fd,
302302
return ORTE_ERR_FILE_OPEN_FAILURE;
303303
}
304304
struct dirent *files;
305+
306+
/* grab the fd of the opendir above so we don't close in the
307+
* middle of the scan. */
308+
int dir_scan_fd = dirfd(dir);
309+
if(dir_scan_fd < 0 ) {
310+
return ORTE_ERR_FILE_OPEN_FAILURE;
311+
}
312+
313+
305314
while (NULL != (files = readdir(dir))) {
306315
if (!isdigit(files->d_name[0])) {
307316
continue;
@@ -315,7 +324,8 @@ static int close_open_file_descriptors(int write_fd,
315324
#if OPAL_PMIX_V1
316325
fd != opts.p_internal[1] &&
317326
#endif
318-
fd != write_fd) {
327+
fd != write_fd &&
328+
fd != dir_scan_fd) {
319329
close(fd);
320330
}
321331
}

0 commit comments

Comments
 (0)