Skip to content

Commit af5dd49

Browse files
bosilcarhc54
authored andcommitted
Optimize the file descriptor cleanup on OSX
Signed-off-by: George Bosilca <[email protected]> Signed-off-by: Jeff Squyres <[email protected]>
1 parent 137cc3d commit af5dd49

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/mca/pfexec/linux/pfexec_linux.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
33
* University Research and Technology
44
* Corporation. All rights reserved.
5-
* Copyright (c) 2004-2008 The University of Tennessee and The University
5+
* Copyright (c) 2004-2022 The University of Tennessee and The University
66
* of Tennessee Research Foundation. All rights
77
* reserved.
88
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -301,7 +301,11 @@ static void send_error_show_help(int fd, int exit_status, const char *file, cons
301301
the pipe up to the parent, and the keepalive pipe. */
302302
static int close_open_file_descriptors(int write_fd, int keepalive)
303303
{
304+
#if defined(__OSX__)
305+
DIR *dir = opendir("/dev/fd");
306+
#else /* Linux */
304307
DIR *dir = opendir("/proc/self/fd");
308+
#endif /* defined(__OSX__) */
305309
if (NULL == dir) {
306310
return PMIX_ERR_FILE_OPEN_FAILURE;
307311
}

src/util/pmix_fd.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* Copyright (c) 2015 Research Organization for Information Science
66
* and Technology (RIST). All rights reserved.
77
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
8+
* Copyright (c) 2022 The University of Tennessee and The University
9+
* of Tennessee Research Foundation. All rights
10+
* reserved.
811
* $COPYRIGHT$
912
*
1013
* Additional copyrights may follow
@@ -201,7 +204,11 @@ static int fdmax = -1;
201204
and the pipe up to the parent. */
202205
void pmix_close_open_file_descriptors(int protected_fd)
203206
{
207+
#if defined(__OSX__)
208+
DIR *dir = opendir("/dev/fd");
209+
#else /* Linux */
204210
DIR *dir = opendir("/proc/self/fd");
211+
#endif /* defined(__OSX__) */
205212
struct dirent *files;
206213
int dir_scan_fd = -1;
207214

0 commit comments

Comments
 (0)