ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/ptytty.C
(Generate patch)

Comparing rxvt-unicode/src/ptytty.C (file contents):
Revision 1.26 by root, Mon Jan 2 15:10:18 2006 UTC vs.
Revision 1.30 by root, Fri Jan 6 05:37:59 2006 UTC

2 * File: ptytty.C 2 * File: ptytty.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com> 6 * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com>
7 * Copyright (c) 2004 Marc Lehmann <pcg@goof.com> 7 * Copyright (c) 2004-2006 Marc Lehmann <pcg@goof.com>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version. 12 * (at your option) any later version.
76 int pfd; 76 int pfd;
77 77
78#ifdef PTYS_ARE_OPENPTY 78#ifdef PTYS_ARE_OPENPTY
79 char tty_name[sizeof "/dev/pts/????\0"]; 79 char tty_name[sizeof "/dev/pts/????\0"];
80 80
81 rxvt_privileges(RESTORE);
81 if (openpty (&pfd, fd_tty, tty_name, NULL, NULL) != -1) 82 int res = openpty (&pfd, fd_tty, tty_name, NULL, NULL);
83 rxvt_privileges(IGNORE);
84
85 if (res != -1)
82 { 86 {
83 *ttydev = strdup (tty_name); 87 *ttydev = strdup (tty_name);
84 return pfd; 88 return pfd;
85 } 89 }
86#endif 90#endif
392 396
393void 397void
394 398
395rxvt_ptytty::close_tty () 399rxvt_ptytty::close_tty ()
396{ 400{
397 if (tty >= 0) close (tty); 401 if (tty < 0)
402 return;
403
404 close (tty);
398 tty = -1; 405 tty = -1;
399} 406}
400 407
401void 408void
402rxvt_ptytty::put () 409rxvt_ptytty::put ()
403{ 410{
404#ifndef NO_SETOWNER_TTYDEV 411#ifndef NO_SETOWNER_TTYDEV
405 if (tty >= 0)
406 privileges (RESTORE); 412 privileges (RESTORE);
407#endif 413#endif
408 414
409 if (pty >= 0) close (pty); 415 if (pty >= 0) close (pty);
410 close_tty (); 416 close_tty ();
411 free (name); 417 free (name);
448 454
449void 455void
450rxvt_ptytty::set_utf8_mode (bool on) 456rxvt_ptytty::set_utf8_mode (bool on)
451{ 457{
452#ifdef IUTF8 458#ifdef IUTF8
453 if (pty != -1) 459 if (pty < 0)
454 { 460 return;
461
455 struct termios tio; 462 struct termios tio;
456 463
457 if (tcgetattr (pty, &tio) != -1) 464 if (tcgetattr (pty, &tio) != -1)
465 {
466 tcflag_t new_cflag = tio.c_iflag;
467
468 if (on)
469 new_cflag |= IUTF8;
470 else
471 new_cflag &= ~IUTF8;
472
473 if (new_cflag != tio.c_iflag)
458 { 474 {
459 tcflag_t new_cflag = tio.c_iflag;
460
461 if (on)
462 new_cflag |= IUTF8;
463 else
464 new_cflag &= ~IUTF8;
465
466 if (new_cflag != tio.c_iflag)
467 {
468 tio.c_iflag = new_cflag; 475 tio.c_iflag = new_cflag;
469 tcsetattr (pty, TCSANOW, &tio); 476 tcsetattr (pty, TCSANOW, &tio);
470 }
471 } 477 }
472 } 478 }
473#endif 479#endif
474} 480}
475 481

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines