1
1

Close oob/usock connections upon exec

Этот коммит содержится в:
Ralph Castain 2014-12-13 20:24:09 -08:00
родитель 6c4d5a51c4
Коммит f4ff791335
2 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -58,6 +58,7 @@
#include "opal/util/output.h" #include "opal/util/output.h"
#include "opal/util/net.h" #include "opal/util/net.h"
#include "opal/util/error.h" #include "opal/util/error.h"
#include "opal/util/fd.h"
#include "opal/class/opal_hash_table.h" #include "opal/class/opal_hash_table.h"
#include "opal/mca/event/event.h" #include "opal/mca/event/event.h"
@ -104,6 +105,14 @@ static int usock_peer_create_socket(mca_oob_usock_peer_t* peer)
opal_socket_errno); opal_socket_errno);
return ORTE_ERR_UNREACH; return ORTE_ERR_UNREACH;
} }
/* Set this fd to be close-on-exec so that subsequent children don't see it */
if (opal_fd_set_cloexec(peer->sd) != OPAL_SUCCESS) {
opal_output(0, "%s unable to set socket to CLOEXEC",
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
close(peer->sd);
peer->sd = -1;
return ORTE_ERROR;
}
/* setup event callbacks */ /* setup event callbacks */
usock_peer_event_init(peer); usock_peer_event_init(peer);

Просмотреть файл

@ -52,6 +52,7 @@
#include "opal/util/error.h" #include "opal/util/error.h"
#include "opal/util/output.h" #include "opal/util/output.h"
#include "opal/opal_socket_errno.h" #include "opal/opal_socket_errno.h"
#include "opal/util/fd.h"
#include "opal/util/if.h" #include "opal/util/if.h"
#include "opal/util/net.h" #include "opal/util/net.h"
#include "opal/util/argv.h" #include "opal/util/argv.h"
@ -96,6 +97,13 @@ int orte_oob_usock_start_listening(void)
} }
return ORTE_ERR_IN_ERRNO; return ORTE_ERR_IN_ERRNO;
} }
/* Set this fd to be close-on-exec so that children don't see it */
if (opal_fd_set_cloexec(sd) != OPAL_SUCCESS) {
opal_output(0, "%s unable to set socket to CLOEXEC",
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
close(sd);
return ORTE_ERROR;
}
addrlen = sizeof(struct sockaddr_un); addrlen = sizeof(struct sockaddr_un);
if (bind(sd, (struct sockaddr*)&mca_oob_usock_component.address, addrlen) < 0) { if (bind(sd, (struct sockaddr*)&mca_oob_usock_component.address, addrlen) < 0) {