mirror of https://github.com/krallin/tini.git
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
This commit is contained in:
parent
40d313000c
commit
82acbc5ccc
11
src/tini.c
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…
Reference in New Issue