Merge pull request #911 from rhc54/topic/cleanup
Cleanup the odls "close file descriptor" commit to conform to OMPI co…
Этот коммит содержится в:
Коммит
13def2a69b
@ -15,7 +15,7 @@
|
|||||||
* Copyright (c) 2010 IBM Corporation. All rights reserved.
|
* Copyright (c) 2010 IBM Corporation. All rights reserved.
|
||||||
* Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights
|
* Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
* Copyright (c) 2013-2014 Intel, Inc. All rights reserved
|
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
|
||||||
*
|
*
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
@ -361,20 +361,30 @@ static int close_open_file_descriptors(int write_fd,
|
|||||||
int pid = getpid();
|
int pid = getpid();
|
||||||
char *fds_dir = NULL;
|
char *fds_dir = NULL;
|
||||||
int rc = asprintf(&fds_dir, "/proc/%d/fd", pid);
|
int rc = asprintf(&fds_dir, "/proc/%d/fd", pid);
|
||||||
if (rc < 0) return ORTE_ERR_OUT_OF_RESOURCE;
|
if (rc < 0) {
|
||||||
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
||||||
|
}
|
||||||
DIR *dir = opendir(fds_dir);
|
DIR *dir = opendir(fds_dir);
|
||||||
free(fds_dir);
|
free(fds_dir);
|
||||||
if (dir == NULL) return ORTE_ERR_FILE_OPEN_FAILURE;
|
if (NULL == dir) {
|
||||||
|
return ORTE_ERR_FILE_OPEN_FAILURE;
|
||||||
|
}
|
||||||
struct dirent *files;
|
struct dirent *files;
|
||||||
while ((files = readdir(dir)) != NULL) {
|
while (NULL != (files = readdir(dir))) {
|
||||||
if(!strncmp(files->d_name,".",1) || !strncmp(files->d_name,"..",2))
|
if (0 == strncmp(files->d_name,".",1) ||
|
||||||
|
0 == strncmp(files->d_name,"..",2)) {
|
||||||
continue;
|
continue;
|
||||||
unsigned int fd = strtoul(files->d_name, NULL, 10);
|
}
|
||||||
if (errno == EINVAL || errno == ERANGE) return ORTE_ERR_TYPE_MISMATCH;
|
int fd = strtol(files->d_name, NULL, 10);
|
||||||
|
if (errno == EINVAL || errno == ERANGE) {
|
||||||
|
closedir(dir);
|
||||||
|
return ORTE_ERR_TYPE_MISMATCH;
|
||||||
|
}
|
||||||
if (fd >=3 && fd != opts.p_internal[1] && fd != write_fd) {
|
if (fd >=3 && fd != opts.p_internal[1] && fd != write_fd) {
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
closedir(dir);
|
||||||
return ORTE_SUCCESS;
|
return ORTE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user