--- rxvt-unicode/src/ptytty.C 2006/01/02 15:10:18 1.26 +++ rxvt-unicode/src/ptytty.C 2006/01/06 02:11:15 1.29 @@ -78,7 +78,11 @@ #ifdef PTYS_ARE_OPENPTY char tty_name[sizeof "/dev/pts/????\0"]; - if (openpty (&pfd, fd_tty, tty_name, NULL, NULL) != -1) + rxvt_privileges(RESTORE); + int res = openpty (&pfd, fd_tty, tty_name, NULL, NULL); + rxvt_privileges(IGNORE); + + if (res != -1) { *ttydev = strdup (tty_name); return pfd; @@ -394,7 +398,10 @@ rxvt_ptytty::close_tty () { - if (tty >= 0) close (tty); + if (tty < 0) + return; + + close (tty); tty = -1; } @@ -402,8 +409,7 @@ rxvt_ptytty::put () { #ifndef NO_SETOWNER_TTYDEV - if (tty >= 0) - privileges (RESTORE); + privileges (RESTORE); #endif if (pty >= 0) close (pty); @@ -450,24 +456,24 @@ rxvt_ptytty::set_utf8_mode (bool on) { #ifdef IUTF8 - if (pty != -1) + if (pty < 0) + return; + + struct termios tio; + + if (tcgetattr (pty, &tio) != -1) { - struct termios tio; + tcflag_t new_cflag = tio.c_iflag; - if (tcgetattr (pty, &tio) != -1) - { - tcflag_t new_cflag = tio.c_iflag; + if (on) + new_cflag |= IUTF8; + else + new_cflag &= ~IUTF8; - if (on) - new_cflag |= IUTF8; - else - new_cflag &= ~IUTF8; - - if (new_cflag != tio.c_iflag) - { - tio.c_iflag = new_cflag; - tcsetattr (pty, TCSANOW, &tio); - } + if (new_cflag != tio.c_iflag) + { + tio.c_iflag = new_cflag; + tcsetattr (pty, TCSANOW, &tio); } } #endif