From: Eric Andersen Date: Wed, 3 Oct 2001 22:10:02 +0000 (-0000) Subject: Fix lash behavior on serial consoles X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=41a82698c313e26aeb43cd57f459ee627319426f;p=oweals%2Fbusybox.git Fix lash behavior on serial consoles --- diff --git a/busybox/lash.c b/busybox/lash.c index 22e3c779e..b3f7cb6a8 100644 --- a/busybox/lash.c +++ b/busybox/lash.c @@ -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); diff --git a/busybox/shell/lash.c b/busybox/shell/lash.c index 22e3c779e..b3f7cb6a8 100644 --- a/busybox/shell/lash.c +++ b/busybox/shell/lash.c @@ -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);