From 87e6232e67ca738ec7ac82084d0d07a27cb1b9c1 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Tue, 22 Apr 2014 21:55:09 +0000 Subject: [PATCH] orterun.c: set an fd to be close-on-exec Make sure the debugger attach fifo is marked as close-on-exec so that children procs don't inherit it. For example, if you salloc a SLURM allocation and run "mpirun ..." in there (i.e., mpirun is running on the head node, and launching on to back-end nodes), the forked srun's will inherit this fd if it is still open. Refs trac:4550 This commit was SVN r31499. The following Trac tickets were found above: Ticket 4550 --> https://svn.open-mpi.org/trac/ompi/ticket/4550 --- orte/tools/orterun/orterun.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/orte/tools/orterun/orterun.c b/orte/tools/orterun/orterun.c index 5a0d695986..0bc852f868 100644 --- a/orte/tools/orterun/orterun.c +++ b/orte/tools/orterun/orterun.c @@ -2999,6 +2999,16 @@ static void open_fifo (void) ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)); return; } + + /* Set this fd to be close-on-exec so that children don't see it */ + if (fcntl(attach_fd, F_SETFD, FD_CLOEXEC) == -1) { + opal_output(0, "%s unable to set debugger attach fifo to CLOEXEC", + ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)); + close(attach_fd); + attach_fd = -1; + return; + } + opal_output_verbose(2, orte_debug_output, "%s Monitoring debugger attach fifo %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),