Skip to content

Commit

Permalink
tty: Set control sessions on pty managers
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Jan 19, 2024
1 parent fa8a6e2 commit e7a681f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions apps/getty.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ int main(int argc, char * argv[]) {
dup2(fd_serial, 0);
dup2(fd_serial, 1);
dup2(fd_serial, 2);
ioctl(STDIN_FILENO, TIOCSCTTY, &(int){1});
tcsetpgrp(STDIN_FILENO, getpid());

system("stty sane");

Expand Down
4 changes: 3 additions & 1 deletion apps/login.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ int main(int argc, char ** argv) {
f = fork();
if (getpid() != pid) {
ioctl(STDIN_FILENO, IOCTLTTYLOGIN, &uid);
toaru_set_credentials(uid);
setsid();
ioctl(STDIN_FILENO, TIOCSCTTY, &(int){1});
tcsetpgrp(STDIN_FILENO, getpid());
toaru_set_credentials(uid);
char * args[] = {
getenv("SHELL"),
NULL
Expand Down
2 changes: 2 additions & 0 deletions apps/netty.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ int main(int argc, char * argv[]) {
dup2(fd_slave, 0);
dup2(fd_slave, 1);
dup2(fd_slave, 2);
ioctl(STDIN_FILENO, TIOCSCTTY, &(int){1});
tcsetpgrp(STDIN_FILENO, getpid());

system("ttysize -q");

Expand Down
2 changes: 2 additions & 0 deletions apps/terminal-vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,8 @@ int main(int argc, char ** argv) {
dup2(fd_slave, 0);
dup2(fd_slave, 1);
dup2(fd_slave, 2);
ioctl(STDIN_FILENO, TIOCSCTTY, &(int){1});
tcsetpgrp(STDIN_FILENO, getpid());

if (argv[optind] != NULL) {
char * tokens[] = {argv[optind], NULL};
Expand Down
1 change: 1 addition & 0 deletions apps/terminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2689,6 +2689,7 @@ int main(int argc, char ** argv) {
dup2(fd_slave, 1);
dup2(fd_slave, 2);

ioctl(STDIN_FILENO, TIOCSCTTY, &(int){1});
tcsetpgrp(STDIN_FILENO, getpid());

/* Set the TERM environment variable. */
Expand Down

0 comments on commit e7a681f

Please sign in to comment.