static sigset_t ttyblock;
-static pid_t parent, child;
+static pid_t ppgrp, child;
static int child_status;
static int foreground;
static void
check_foreground(void)
{
- foreground = tcgetpgrp(script_fds[SFD_USERTTY]) == parent;
+ foreground = tcgetpgrp(script_fds[SFD_USERTTY]) == ppgrp;
if (foreground && !tty_initialized) {
if (term_copy(script_fds[SFD_USERTTY], script_fds[SFD_SLAVE], ttyout)) {
tty_initialized = 1;
sa.sa_handler = SIG_DFL;
sigaction(signo, &sa, &osa);
sudo_debug(8, "kill parent %d", signo);
- kill(parent, signo);
+ killpg(ppgrp, signo);
/* Check foreground/background status on resume. */
check_foreground();
}
#endif
- parent = getpid(); /* so child can pass signals back to us */
+ ppgrp = getpgrp(); /* parent's pgrp, so child can signal us */
/*
* We communicate with the child over a bi-directional pipe.
sigaddset(&ttyblock, SIGTTOU);
/* Are we the foreground process? */
- foreground = tcgetpgrp(script_fds[SFD_USERTTY]) == parent;
+ foreground = tcgetpgrp(script_fds[SFD_USERTTY]) == ppgrp;
/* If stdout is not a tty we handle post-processing differently. */
ttyout = isatty(STDOUT_FILENO);