Fix lash behavior on serial consoles
authorEric Andersen <andersen@codepoet.org>
Wed, 3 Oct 2001 22:10:02 +0000 (22:10 -0000)
committerEric Andersen <andersen@codepoet.org>
Wed, 3 Oct 2001 22:10:02 +0000 (22:10 -0000)
busybox/lash.c
busybox/shell/lash.c

index 22e3c779eec2e95aef0a4ac2db52c09519c43e97..b3f7cb6a80e088d39fdf61b7cc708ad7913fb700 100644 (file)
@@ -1524,9 +1524,15 @@ void free_memory(void)
  * we don't fight over who gets the foreground */
 static void setup_job_control()
 {
+       int status;
+       
        /* Loop until we are in the foreground.  */
-       while (tcgetpgrp (shell_terminal) != (shell_pgrp = getpgrp ()))
+       while ((status = tcgetpgrp (shell_terminal)) >= 0) {
+               if (status == (shell_pgrp = getpgrp ())) {
+                       break;
+               }
                kill (- shell_pgrp, SIGTTIN);
+       }
 
        /* Ignore interactive and job-control signals.  */
        signal(SIGINT, SIG_IGN);
index 22e3c779eec2e95aef0a4ac2db52c09519c43e97..b3f7cb6a80e088d39fdf61b7cc708ad7913fb700 100644 (file)
@@ -1524,9 +1524,15 @@ void free_memory(void)
  * we don't fight over who gets the foreground */
 static void setup_job_control()
 {
+       int status;
+       
        /* Loop until we are in the foreground.  */
-       while (tcgetpgrp (shell_terminal) != (shell_pgrp = getpgrp ()))
+       while ((status = tcgetpgrp (shell_terminal)) >= 0) {
+               if (status == (shell_pgrp = getpgrp ())) {
+                       break;
+               }
                kill (- shell_pgrp, SIGTTIN);
+       }
 
        /* Ignore interactive and job-control signals.  */
        signal(SIGINT, SIG_IGN);