Make child process group foreground on active tty

When a tty is available, make the child process group foreground on
(and graciously fallback if no tty is available).

Fix #19
pull/21/head
Thomas Orozco 9 years ago
parent 40d313000c
commit 82acbc5ccc
  1. 11
      src/tini.c

@ -83,6 +83,17 @@ int spawn(const sigset_t* const child_sigset_ptr, char* const argv[], int* const
// Parent
PRINT_INFO("Spawned child process '%s' with pid '%i'", argv[0], pid);
*child_pid_ptr = pid;
// If there is a tty, pass control over to the child process group
if (tcsetpgrp(STDIN_FILENO, pid)) {
if (errno == ENOTTY) {
PRINT_DEBUG("tcsetpgrp failed: no tty (ok to proceed)")
} else {
PRINT_FATAL("tcsetpgrp failed: '%s'", strerror(errno));
return 1;
}
}
return 0;
}
}

Loading…
Cancel
Save