=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.20 retrieving revision 1.21 diff -c -r1.20 -r1.21 *** src/usr.bin/tmux/tty.c 2009/08/11 19:32:25 1.20 --- src/usr.bin/tmux/tty.c 2009/08/11 20:29:05 1.21 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.20 2009/08/11 19:32:25 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.21 2009/08/11 20:29:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 80,87 **** tty->log_fd = -1; tty->term = tty_term_find(tty->termname, tty->fd, overrides, cause); ! if (tty->term == NULL) ! goto error; tty->in = buffer_create(BUFSIZ); tty->out = buffer_create(BUFSIZ); --- 80,90 ---- tty->log_fd = -1; tty->term = tty_term_find(tty->termname, tty->fd, overrides, cause); ! if (tty->term == NULL) { ! tty_close(tty); ! return (-1); ! } ! tty->flags |= TTY_OPENED; tty->in = buffer_create(BUFSIZ); tty->out = buffer_create(BUFSIZ); *************** *** 95,106 **** tty_fill_acs(tty); return (0); - - error: - close(tty->fd); - tty->fd = -1; - - return (-1); } void --- 98,103 ---- *************** *** 289,297 **** void tty_close(struct tty *tty) { - if (tty->fd == -1) - return; - if (tty->log_fd != -1) { close(tty->log_fd); tty->log_fd = -1; --- 286,291 ---- *************** *** 299,312 **** tty_stop_tty(tty); ! tty_term_free(tty->term); ! tty_keys_free(tty); ! close(tty->fd); ! tty->fd = -1; ! buffer_destroy(tty->in); ! buffer_destroy(tty->out); } void --- 293,312 ---- tty_stop_tty(tty); ! if (tty->flags & TTY_OPENED) { ! tty_term_free(tty->term); ! tty_keys_free(tty); ! buffer_destroy(tty->in); ! buffer_destroy(tty->out); ! tty->flags &= ~TTY_OPENED; ! } ! ! if (tty->fd != -1) { ! close(tty->fd); ! tty->fd = -1; ! } } void