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()
{
- 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;
#ifdef SCRIPT_DEBUG
warningx("kill parent %d", signo);
#endif
- kill(parent, signo);
+ killpg(ppgrp, signo);
/* Check foreground/background status on resume. */
check_foreground();
#endif
/* Are we the foreground process? */
- parent = getpid(); /* so child can pass signals back to us */
- foreground = tcgetpgrp(script_fds[SFD_USERTTY]) == parent;
+ ppgrp = getpgrp(); /* so child can pass signals back to us */
+ foreground = tcgetpgrp(script_fds[SFD_USERTTY]) == ppgrp;
/* So we can block tty-generated signals */
sigemptyset(&ttyblock);