]> granicus.if.org Git - sudo/commitdiff
In non-pty mode before continuing the child, make it the foreground
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 2 Feb 2011 19:26:41 +0000 (14:26 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 2 Feb 2011 19:26:41 +0000 (14:26 -0500)
pgrp if possible.  Fixes resuming a shell.

--HG--
branch : 1.7

exec.c

diff --git a/exec.c b/exec.c
index d9c3608b035384feec016d4c4500d3b3dc08a56b..4b402213d0a66fe379d6ad1e3daae46695c4bd28 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -498,6 +498,18 @@ handle_signals(fd, child, cstat)
            } else
 #endif
            {
+               if (signo == SIGCONT) {
+                   /*
+                    * Before continuing the child, make it the foreground
+                    * pgrp if possible.  Fixes resuming a shell.
+                    */
+                   int fd = open(_PATH_TTY, O_RDWR|O_NOCTTY, 0);
+                   if (fd != -1) {
+                       if (tcgetpgrp(fd) == getpgrp())
+                           (void)tcsetpgrp(fd, child);
+                       close(fd);
+                   }
+               }
                /* Nothing listening on sv[0], send directly. */
                kill(child, signo);
            }