--- rxvt-unicode/src/ptytty.C 2007/06/26 00:40:28 1.64 +++ rxvt-unicode/src/ptytty.C 2007/12/11 21:49:12 1.68 @@ -88,7 +88,8 @@ { if (grantpt (pfd) == 0 /* change slave permissions */ && unlockpt (pfd) == 0) - { /* slave now unlocked */ + { + /* slave now unlocked */ *ttydev = strdup (ptsname (pfd)); /* get slave's name */ return pfd; } @@ -106,13 +107,12 @@ { int pfd; int res; - char tty_name[32]; - res = openpty (&pfd, fd_tty, tty_name, NULL, NULL); + res = openpty (&pfd, fd_tty, NULL, NULL, NULL); if (res != -1) { - *ttydev = strdup (tty_name); + *ttydev = strdup (ttyname (*fd_tty)); return pfd; } @@ -125,11 +125,14 @@ get_pty (int *fd_tty, char **ttydev) { int pfd; + char *slave; - *ttydev = _getpty (&pfd, O_RDWR | O_NONBLOCK | O_NOCTTY, 0622, 0); + slave = _getpty (&pfd, O_RDWR | O_NONBLOCK | O_NOCTTY, 0622, 0); - if (*ttydev != NULL) + if (slave != NULL) { + *ttydev = strdup (slave); return pfd; + } return -1; } @@ -223,6 +226,8 @@ static int control_tty (int fd_tty) { + int fd; + setsid (); #if defined(HAVE_DEV_PTMX) && defined(I_PUSH) @@ -256,12 +261,12 @@ #ifdef TIOCSCTTY ioctl (fd_tty, TIOCSCTTY, NULL); #else - fd = open (name, O_RDWR); + fd = open (ttyname (fd_tty), O_RDWR); if (fd >= 0) close (fd); #endif - int fd = open ("/dev/tty", O_WRONLY); + fd = open ("/dev/tty", O_WRONLY); if (fd < 0) return -1; /* fatal */ @@ -323,12 +328,13 @@ struct group *gr = getgrnam ("tty"); if (gr) - { /* change group ownership of tty to "tty" */ + { + /* change group ownership of tty to "tty" */ mode = S_IRUSR | S_IWUSR | S_IWGRP; gid = gr->gr_gid; } else -#endif /* TTY_GID_SUPPORT */ +#endif /* TTY_GID_SUPPORT */ { mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; gid = 0;