Gerrit and Moe,

Suppose we change the "is_interactive" test to allow us to have it both 
ways?    Consider the following patch (against version 2.2.1):

Index: salloc.c
===================================================================
RCS file: /cvsroot/slurm/slurm/src/salloc/salloc.c,v
retrieving revision 1.1.1.40
diff -u -r1.1.1.40 salloc.c
--- salloc.c    28 Jan 2011 17:45:59 -0000      1.1.1.40
+++ salloc.c    11 Feb 2011 16:06:16 -0000
@@ -162,19 +162,8 @@
        static char *msg = "Slurm job queue full, sleeping and retrying.";
        slurm_allocation_callbacks_t callbacks;

-       is_interactive = isatty(STDIN_FILENO);
+       is_interactive = isatty(STDIN_FILENO) && (tcgetpgrp(STDIN_FILENO) 
== (pid = getpgrp()));
        if (is_interactive) {
-               bool sent_msg = false;
-               /* Wait as long as we are running in the background */
-               while (tcgetpgrp(STDIN_FILENO) != (pid = getpgrp())) {
-                       if (!sent_msg) {
-                               error("Waiting for program to be placed in 
"
-                                     "the foreground");
-                               sent_msg = true;
-                       }
-                       killpg(pid, SIGTTIN);
-               }
-
                /*
                 * Save tty attributes and reset at exit, in case a child
                 * process died before properly resetting terminal.


This change allows salloc to run in the background if requested,  but 
still preserves the tty attributes of the terminal if the process is 
running in the foreground. It also avoids having to use the "trick" of 
using input redirection (</dev/null)  in order to fool the code, and keeps 
the original semantics of salloc for those who use it to, for example, 
launch an xterm or run jobs using mpirun.    And we don't have to change 
the documentation, either.

        -Don Albert-

Reply via email to