From 410f5bfb91b73ebe130bcfb12b349bc065a443dd Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 23 Apr 2014 21:46:41 +0000 Subject: [PATCH] oob_tcp_listener.c: set both ends of this thread to be close-on-exec This pipe is used to communicate between threads in this process. Mark both fd as close-on-exec so that children don't inherit this pipe. Refs trac:4550 This commit was SVN r31512. The following Trac tickets were found above: Ticket 4550 --> https://svn.open-mpi.org/trac/ompi/ticket/4550 --- orte/mca/oob/tcp/oob_tcp_listener.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/orte/mca/oob/tcp/oob_tcp_listener.c b/orte/mca/oob/tcp/oob_tcp_listener.c index 5a500316aa..822383be6b 100644 --- a/orte/mca/oob/tcp/oob_tcp_listener.c +++ b/orte/mca/oob/tcp/oob_tcp_listener.c @@ -129,6 +129,17 @@ int orte_oob_tcp_start_listening(void) ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); return ORTE_ERR_OUT_OF_RESOURCE; } + + /* Make sure the pipe FDs are set to close-on-exec so that + they don't leak into children */ + if (fcntl(mca_oob_tcp_component.stop_thread[0], F_SETFD, FD_CLOEXEC) == -1 || + fcntl(mca_oob_tcp_component.stop_thread[1], F_SETFD, FD_CLOEXEC) == -1) { + close(mca_oob_tcp_component.stop_thread[0]); + close(mca_oob_tcp_component.stop_thread[1]); + ORTE_ERROR_LOG(ORTE_ERR_IN_ERRNO); + return ORTE_ERR_IN_ERRNO; + } + mca_oob_tcp_component.listen_thread_active = true; mca_oob_tcp_component.listen_thread.t_run = listen_thread; mca_oob_tcp_component.listen_thread.t_arg = NULL;