From 29f9e23c8495f71601b0a66a3b1c1b726d52e4cc Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 2 Feb 2011 14:19:23 -0500 Subject: [PATCH] In non-pty mode before continuing the child, make it the foreground pgrp if possible. Fixes resuming a shell. --- src/exec.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/exec.c b/src/exec.c index f3038a331..463ad9488 100644 --- a/src/exec.c +++ b/src/exec.c @@ -456,6 +456,18 @@ handle_signals(int fd, pid_t child, int log_io, struct command_status *cstat) if (signo == SIGALRM) { terminate_child(child, FALSE); } else { + 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); + } + } kill(child, signo); } } -- 2.40.0