[mpich-commits] r10700 - mpich2/trunk/src/pm/hydra/tools/demux

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


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

Modified:
   mpich2/trunk/src/pm/hydra/tools/demux/demux.c
Log:
Whether mpiexec is attached to a terminal does not make any difference
for our stdin strategy.  Remove that test.

No reviewer.

Modified: mpich2/trunk/src/pm/hydra/tools/demux/demux.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/demux/demux.c	2012-11-30 07:49:00 UTC (rev 10699)
+++ mpich2/trunk/src/pm/hydra/tools/demux/demux.c	2012-11-30 08:50:33 UTC (rev 10700)
@@ -13,7 +13,7 @@
 
 static int got_sigttin = 0;
 
-#if defined(SIGTTIN) && defined(HAVE_ISATTY)
+#if defined(SIGTTIN)
 static void signal_cb(int sig)
 {
     HYDU_FUNC_ENTER();
@@ -25,7 +25,7 @@
     HYDU_FUNC_EXIT();
     return;
 }
-#endif /* SIGTTIN and HAVE_ISATTY */
+#endif /* SIGTTIN */
 
 HYD_status HYDT_dmx_init(char **demux)
 {
@@ -228,25 +228,44 @@
      * that, we catch SIGTTIN and ignore it. But that causes the
      * read() call to return an error (with errno == EINTR) when we
      * are not attached to the terminal. */
-#if defined(SIGTTIN) && defined(HAVE_ISATTY)
-    if (isatty(STDIN_FILENO)) {
-        status = HYDU_set_signal(SIGTTIN, signal_cb);
-        HYDU_ERR_POP(status, "unable to set SIGTTIN\n");
-    }
-#endif /* SIGTTIN and HAVE_ISATTY */
 
+    /*
+     * We need to allow for the following cases:
+     *
+     *  1. mpiexec -n 2 ./foo  --> type something on the terminal
+     *     Attached to terminal, and can read from stdin
+     *
+     *  2. mpiexec -n 2 ./foo &
+     *     Attached to terminal, but cannot read from stdin
+     *
+     *  3. mpiexec -n 2 ./foo < bar
+     *     Not attached to terminal, but can read from stdin
+     *
+     *  4. mpiexec -n 2 ./foo < /dev/null
+     *     Not attached to terminal, and can read from stdin
+     *
+     *  5. mpiexec -n 2 ./foo < bar &
+     *     Not attached to terminal, but can read from stdin
+     *
+     *  6. mpiexec -n 2 ./foo < /dev/null &
+     *     Not attached to terminal, and can read from stdin
+     */
+
+#if defined(SIGTTIN)
+    status = HYDU_set_signal(SIGTTIN, signal_cb);
+    HYDU_ERR_POP(status, "unable to set SIGTTIN\n");
+#endif /* SIGTTIN */
+
     ret = read(STDIN_FILENO, NULL, 0);
-    if (ret < 0 && errno == EINTR && got_sigttin)
+    if (ret == 0)
+        *out = 1;
+    else
         *out = 0;
-    else
-        *out = 1;
 
-#if defined(SIGTTIN) && defined(HAVE_ISATTY)
-    if (isatty(STDIN_FILENO)) {
-        status = HYDU_set_signal(SIGTTIN, SIG_IGN);
-        HYDU_ERR_POP(status, "unable to set SIGTTIN\n");
-    }
-#endif /* SIGTTIN and HAVE_ISATTY */
+#if defined(SIGTTIN)
+    status = HYDU_set_signal(SIGTTIN, SIG_IGN);
+    HYDU_ERR_POP(status, "unable to set SIGTTIN\n");
+#endif /* SIGTTIN */
 
   fn_exit:
     HYDU_FUNC_EXIT();



More information about the commits mailing list