I am submitting this as a bug-fix, after going through the options
of salloc again. If --no-shell is specified, salloc is clearly not
run in interactive mode.


salloc: Option --no-shell means non-interative.

This is an oversight from an earlier patch submission.
---
 src/salloc/salloc.c |   51 ++++++++++++++++++++++++++-------------------------
 1 file changed, 26 insertions(+), 25 deletions(-)

--- a/src/salloc/salloc.c
+++ b/src/salloc/salloc.c
@@ -153,31 +153,6 @@ int main(int argc, char *argv[])
 	static char *msg = "Slurm job queue full, sleeping and retrying.";
 	slurm_allocation_callbacks_t callbacks;
 
-	is_interactive = isatty(STDIN_FILENO);
-	if (is_interactive) {
-		bool sent_msg = false;
-		/*
-		 * Job control: interactive sub-processes run in the foreground
-		 * process group of the controlling terminal. In order to grant
-		 * this (tcsetpgrp), salloc needs to be in the foreground first.
-		 */
-		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.
-		 */
-		tcgetattr (STDIN_FILENO, &saved_tty_attributes);
-		atexit (_reset_input_mode);
-	}
-
 	log_init(xbasename(argv[0]), logopt, 0, NULL);
 	_set_exit_code();
 
@@ -231,6 +206,32 @@ int main(int argc, char *argv[])
 		_set_rlimits(env);
 	}
 
+	if ((!opt.no_shell) && isatty(STDIN_FILENO)) {
+		bool sent_msg = false;
+
+		is_interactive = true;
+		/*
+		 * Job control: interactive sub-processes run in the foreground
+		 * process group of the controlling terminal. In order to grant
+		 * this (tcsetpgrp), salloc needs to be in the foreground first.
+		 */
+		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.
+		 */
+		tcgetattr (STDIN_FILENO, &saved_tty_attributes);
+		atexit (_reset_input_mode);
+	}
+
 	/*
 	 * Request a job allocation
 	 */

Reply via email to