[mpich2-commits] r7485 - in mpich2/trunk/src/pm/hydra: tools/bootstrap/utils tools/demux ui/mpich utils/signals utils/sock

balaji at mcs.anl.gov balaji at mcs.anl.gov
Tue Nov 23 01:21:56 CST 2010


Author: balaji
Date: 2010-11-23 01:21:56 -0600 (Tue, 23 Nov 2010)
New Revision: 7485

Modified:
   mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_cb.c
   mpich2/trunk/src/pm/hydra/tools/demux/demux_poll.c
   mpich2/trunk/src/pm/hydra/tools/demux/demux_select.c
   mpich2/trunk/src/pm/hydra/ui/mpich/mpiexec.c
   mpich2/trunk/src/pm/hydra/utils/signals/signals.c
   mpich2/trunk/src/pm/hydra/utils/sock/sock.c
Log:
Disable reading stdin from the command-line when running in the
background.

Modified: mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_cb.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_cb.c	2010-11-23 07:21:38 UTC (rev 7484)
+++ mpich2/trunk/src/pm/hydra/tools/bootstrap/utils/bscu_cb.c	2010-11-23 07:21:56 UTC (rev 7485)
@@ -32,6 +32,8 @@
         }
 
         close(fd);
+        if (fd == STDIN_FILENO)
+            close(stdfd);
     }
 
   fn_exit:

Modified: mpich2/trunk/src/pm/hydra/tools/demux/demux_poll.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/demux/demux_poll.c	2010-11-23 07:21:38 UTC (rev 7484)
+++ mpich2/trunk/src/pm/hydra/tools/demux/demux_poll.c	2010-11-23 07:21:56 UTC (rev 7485)
@@ -120,6 +120,16 @@
     else
         *out = 1;
 
+    /* This is an extremely round-about way of solving a simple
+     * problem. isatty(STDIN_FILENO) seems to return 1, even when
+     * mpiexec is run in the background. So, instead of relying on
+     * 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. */
+    ret = read(STDIN_FILENO, NULL, 0);
+    if (ret < 0 && errno == EINTR)
+        *out = 0;
+
   fn_exit:
     HYDU_FUNC_EXIT();
     return status;

Modified: mpich2/trunk/src/pm/hydra/tools/demux/demux_select.c
===================================================================
--- mpich2/trunk/src/pm/hydra/tools/demux/demux_select.c	2010-11-23 07:21:38 UTC (rev 7484)
+++ mpich2/trunk/src/pm/hydra/tools/demux/demux_select.c	2010-11-23 07:21:56 UTC (rev 7485)
@@ -113,6 +113,16 @@
     else
         *out = 1;
 
+    /* This is an extremely round-about way of solving a simple
+     * problem. isatty(STDIN_FILENO) seems to return 1, even when
+     * mpiexec is run in the background. So, instead of relying on
+     * 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. */
+    ret = read(STDIN_FILENO, NULL, 0);
+    if (ret < 0 && errno == EINTR)
+        *out = 0;
+
   fn_exit:
     HYDU_FUNC_EXIT();
     return status;

Modified: mpich2/trunk/src/pm/hydra/ui/mpich/mpiexec.c
===================================================================
--- mpich2/trunk/src/pm/hydra/ui/mpich/mpiexec.c	2010-11-23 07:21:38 UTC (rev 7484)
+++ mpich2/trunk/src/pm/hydra/ui/mpich/mpiexec.c	2010-11-23 07:21:56 UTC (rev 7485)
@@ -143,7 +143,7 @@
         cmd = HYD_CKPOINT;
         HYDU_sock_write(HYD_handle.cleanup_pipe[1], &cmd, sizeof(cmd), &sent, &closed);
     }
-    /* Ignore other signals for now */
+    /* Ignore all other signals, including SIGTTIN */
 
     HYDU_FUNC_EXIT();
     return;

Modified: mpich2/trunk/src/pm/hydra/utils/signals/signals.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/signals/signals.c	2010-11-23 07:21:38 UTC (rev 7484)
+++ mpich2/trunk/src/pm/hydra/utils/signals/signals.c	2010-11-23 07:21:56 UTC (rev 7485)
@@ -59,6 +59,11 @@
     status = HYDU_set_signal(SIGALRM, handler);
     HYDU_ERR_POP(status, "unable to set SIGALRM\n");
 
+#ifdef SIGTTIN
+    status = HYDU_set_signal(SIGTTIN, handler);
+    HYDU_ERR_POP(status, "unable to set SIGTTIN\n");
+#endif /* SIGTTIN */
+
   fn_exit:
     HYDU_FUNC_EXIT();
     return status;

Modified: mpich2/trunk/src/pm/hydra/utils/sock/sock.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/sock/sock.c	2010-11-23 07:21:38 UTC (rev 7484)
+++ mpich2/trunk/src/pm/hydra/utils/sock/sock.c	2010-11-23 07:21:56 UTC (rev 7485)
@@ -205,6 +205,13 @@
     while (1) {
         do {
             tmp = read(fd, (char *) buf + *recvd, maxlen - *recvd);
+            if (tmp < 0 && errno == EINTR && fd == STDIN_FILENO) {
+                /* If we get an EINTR on stdin, set the socket to be
+                 * closed and jump out */
+                *closed = 1;
+                status = HYD_SUCCESS;
+                goto fn_exit;
+            }
         } while (tmp < 0 && errno == EINTR);
 
         if (tmp < 0) {



More information about the mpich2-commits mailing list