mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-25 23:08:46 +00:00
Use isolated devpts if kernel support
kernel version >= 4.7 or CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
This commit is contained in:
@@ -156,7 +156,6 @@ int su_client_main(int argc, char *argv[]) {
|
||||
optind++;
|
||||
}
|
||||
|
||||
char pts_slave[PATH_MAX];
|
||||
int ptmx, fd;
|
||||
|
||||
// Connect to client
|
||||
@@ -183,16 +182,6 @@ int su_client_main(int argc, char *argv[]) {
|
||||
if (isatty(STDOUT_FILENO)) atty |= ATTY_OUT;
|
||||
if (isatty(STDERR_FILENO)) atty |= ATTY_ERR;
|
||||
|
||||
if (atty) {
|
||||
// We need a PTY. Get one.
|
||||
ptmx = pts_open(pts_slave, sizeof(pts_slave));
|
||||
} else {
|
||||
pts_slave[0] = '\0';
|
||||
}
|
||||
|
||||
// Send pts_slave
|
||||
write_string(fd, pts_slave);
|
||||
|
||||
// Send stdin
|
||||
send_fd(fd, (atty & ATTY_IN) ? -1 : STDIN_FILENO);
|
||||
// Send stdout
|
||||
@@ -200,6 +189,14 @@ int su_client_main(int argc, char *argv[]) {
|
||||
// Send stderr
|
||||
send_fd(fd, (atty & ATTY_ERR) ? -1 : STDERR_FILENO);
|
||||
|
||||
if (atty) {
|
||||
// We need a PTY. Get one.
|
||||
write_int(fd, 1);
|
||||
ptmx = recv_fd(fd);
|
||||
} else {
|
||||
write_int(fd, 0);
|
||||
}
|
||||
|
||||
if (atty) {
|
||||
setup_sighandlers(sighandler);
|
||||
watch_sigwinch_async(STDOUT_FILENO, ptmx);
|
||||
|
||||
Reference in New Issue
Block a user