> I think a good idea would be to add a detailed comment in the code to this 
> fact, so we don't forget
> why the test is there
I hope that the following is sufficient?

--- a/src/salloc/salloc.c
+++ b/src/salloc/salloc.c
@@ -156,7 +156,11 @@ int main(int argc, char *argv[])
        is_interactive = isatty(STDIN_FILENO);
        if (is_interactive) {
                bool sent_msg = false;
-               /* Wait as long as we are running in the background */
+               /*
+                * 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 "


--- a/src/salloc/salloc.c
+++ b/src/salloc/salloc.c
@@ -156,7 +156,11 @@ int main(int argc, char *argv[])
 	is_interactive = isatty(STDIN_FILENO);
 	if (is_interactive) {
 		bool sent_msg = false;
-		/* Wait as long as we are running in the background */
+		/*
+		 * 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 "

Reply via email to