slave: configure pts to be the controlling terminal of the forked process

This commit is contained in:
Daniel Eklöf 2020-05-13 13:04:52 +02:00
parent 980606233b
commit e654cf3880
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 8 additions and 0 deletions

View file

@ -10,6 +10,7 @@
#include <signal.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#define LOG_MODULE "slave"
@ -93,6 +94,12 @@ slave_exec(int ptmx, char *argv[], int err_fd, bool login_shell)
goto err;
}
if (ioctl(pts, TIOCSCTTY, 0) < 0) {
LOG_ERRNO("failed to configure controlling terminal");
goto err;
}
if (dup2(pts, STDIN_FILENO) == -1 ||
dup2(pts, STDOUT_FILENO) == -1 ||
dup2(pts, STDERR_FILENO) == -1)