diff --git a/orte/mca/ess/hnp/ess_hnp_module.c b/orte/mca/ess/hnp/ess_hnp_module.c index 29ae80fb88..4102ecacf2 100644 --- a/orte/mca/ess/hnp/ess_hnp_module.c +++ b/orte/mca/ess/hnp/ess_hnp_module.c @@ -10,7 +10,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved. - * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2011-2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2013-2014 Intel, Inc. All rights reserved. @@ -48,6 +48,7 @@ #include "opal/util/output.h" #include "opal/util/malloc.h" #include "opal/util/basename.h" +#include "opal/util/fd.h" #include "opal/mca/pstat/base/base.h" #include "opal/mca/hwloc/base/base.h" @@ -166,6 +167,15 @@ static int rte_init(void) opal_event_set(orte_event_base, &term_handler, term_pipe[0], OPAL_EV_READ, clean_abort, NULL); opal_event_set_priority(&term_handler, ORTE_ERROR_PRI); opal_event_add(&term_handler, NULL); + + /* Set both ends of this pipe to be close-on-exec so that no + children inherit it */ + if (opal_fd_set_cloexec(term_pipe[0]) != OPAL_SUCCESS || + opal_fd_set_cloexec(term_pipe[1]) != OPAL_SUCCESS) { + error = "unable to set the pipe to CLOEXEC"; + goto error; + } + /* point the signal trap to a function that will activate that event */ signal(SIGTERM, abort_signal_callback); signal(SIGINT, abort_signal_callback); diff --git a/orte/mca/oob/tcp/oob_tcp_listener.c b/orte/mca/oob/tcp/oob_tcp_listener.c index bbffaec7e3..22f2b131a7 100644 --- a/orte/mca/oob/tcp/oob_tcp_listener.c +++ b/orte/mca/oob/tcp/oob_tcp_listener.c @@ -11,7 +11,7 @@ * All rights reserved. * Copyright (c) 2006-2013 Los Alamos National Security, LLC. * All rights reserved. - * Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2009-2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. * Copyright (c) 2013-2014 Intel, Inc. All rights reserved. * $COPYRIGHT$ @@ -322,6 +322,17 @@ static int create_listen(void) return ORTE_ERROR; } + /* Set the socket to close-on-exec so that no children inherit + this FD */ + if (opal_fd_set_cloexec(sd) != OPAL_SUCCESS) { + opal_output(0, "mca_oob_tcp_create_listen: unable to set the " + "listening socket to CLOEXEC (%s:%d)\n", + strerror(opal_socket_errno), opal_socket_errno); + CLOSE_THE_SOCKET(sd); + opal_argv_free(ports); + return ORTE_ERROR; + } + if (bind(sd, (struct sockaddr*)&inaddr, addrlen) < 0) { if( (EADDRINUSE == opal_socket_errno) || (EADDRNOTAVAIL == opal_socket_errno) ) { continue;