[mpich-commits] r10701 - in mpich2/trunk/src/pm/hydra: tools/demux ui/mpich

balaji at mcs.anl.gov balaji at mcs.anl.gov
Fri Nov 30 02:50:40 CST 2012


Author: balaji
Date: 2012-11-30 02:50:40 -0600 (Fri, 30 Nov 2012)
New Revision: 10701

Modified:
   mpich2/trunk/src/pm/hydra/tools/demux/demux.c
   mpich2/trunk/src/pm/hydra/ui/mpich/mpiexec.c
Log:
Check for STDIN validity before any other sockets are opened.  This is
to cover the case where an external script closed STDIN before calling
mpiexec.

No reviewer.

Modified: mpich2/trunk/src/pm/hydra/tools/demux/demux.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/demux/demux.c	2012-11-30 08:50:33 UTC (rev 10700)
+++ mpich2/trunk/src/pm/hydra/tools/demux/demux.c	2012-11-30 08:50:40 UTC (rev 10701)
@@ -12,6 +12,7 @@
 struct HYDT_dmxu_fns HYDT_dmxu_fns = { 0 };
 
 static int got_sigttin = 0;
+static int stdin_valid;
 
 #if defined(SIGTTIN)
 static void signal_cb(int sig)
@@ -63,6 +64,9 @@
                             "cannot find an appropriate demux engine\n");
     }
 
+    status = HYDT_dmxu_fns.stdin_valid(&stdin_valid);
+    HYDU_ERR_POP(status, "error checking for stdin validity\n");
+
   fn_exit:
     HYDU_FUNC_EXIT();
     return status;
@@ -277,5 +281,7 @@
 
 HYD_status HYDT_dmx_stdin_valid(int *out)
 {
-    return HYDT_dmxu_fns.stdin_valid(out);
+    *out = stdin_valid;
+
+    return HYD_SUCCESS;
 }

Modified: mpich2/trunk/src/pm/hydra/ui/mpich/mpiexec.c
===================================================================
--- mpich2/trunk/src/pm/hydra/ui/mpich/mpiexec.c	2012-11-30 08:50:33 UTC (rev 10700)
+++ mpich2/trunk/src/pm/hydra/ui/mpich/mpiexec.c	2012-11-30 08:50:40 UTC (rev 10701)
@@ -144,18 +144,13 @@
     status = HYDU_set_common_signals(signal_cb);
     HYDU_ERR_POP(status, "unable to set signal\n");
 
-    if (pipe(HYD_server_info.cmd_pipe) < 0)
-        HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "pipe error\n");
-
     status = HYDT_ftb_init();
     HYDU_ERR_POP(status, "unable to initialize FTB\n");
 
-
     /* Get user preferences */
     status = HYD_uii_mpx_get_parameters(argv);
     HYDU_ERR_POP(status, "error parsing parameters\n");
 
-
     /* Now we initialize engines that require us to know user
      * preferences */
 #if HAVE_ALARM
@@ -163,6 +158,10 @@
         alarm(HYD_ui_mpich_info.ckpoint_int);
 #endif /* HAVE_ALARM */
 
+    /* The demux engine should be initialized before any sockets are
+     * created, since it checks for STDIN's validity.  If STDIN was
+     * closed and we opened a socket that got the same fd as STDIN,
+     * this test will not be possible. */
     status = HYDT_dmx_init(&HYD_server_info.user_global.demux);
     HYDU_ERR_POP(status, "unable to initialize the demux engine\n");
 
@@ -318,6 +317,10 @@
     HYD_server_info.stdout_cb = HYD_uiu_stdout_cb;
     HYD_server_info.stderr_cb = HYD_uiu_stderr_cb;
 
+    /* Create a pipe connection to wake up the process manager */
+    if (pipe(HYD_server_info.cmd_pipe) < 0)
+        HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "pipe error\n");
+
     /* Launch the processes */
     status = HYD_pmci_launch_procs();
     HYDU_ERR_POP(status, "process manager returned error launching processes\n");



More information about the commits mailing list