=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty.c,v retrieving revision 1.257 retrieving revision 1.258 diff -c -r1.257 -r1.258 *** src/usr.bin/tmux/tty.c 2017/04/05 10:45:20 1.257 --- src/usr.bin/tmux/tty.c 2017/04/05 10:49:46 1.258 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.257 2017/04/05 10:45:20 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.258 2017/04/05 10:49:46 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 94,101 **** int tty_init(struct tty *tty, struct client *c, int fd, char *term) { - char *path; - if (!isatty(fd)) return (-1); --- 94,99 ---- *************** *** 105,116 **** tty->term_name = xstrdup("unknown"); else tty->term_name = xstrdup(term); tty->fd = fd; tty->client = c; - if ((path = ttyname(fd)) == NULL) - return (-1); - tty->path = xstrdup(path); tty->cstyle = 0; tty->ccolour = xstrdup(""); --- 103,112 ---- tty->term_name = xstrdup("unknown"); else tty->term_name = xstrdup(term); + tty->fd = fd; tty->client = c; tty->cstyle = 0; tty->ccolour = xstrdup(""); *************** *** 125,132 **** int tty_resize(struct tty *tty) { ! struct winsize ws; ! u_int sx, sy; if (ioctl(tty->fd, TIOCGWINSZ, &ws) != -1) { sx = ws.ws_col; --- 121,129 ---- int tty_resize(struct tty *tty) { ! struct client *c = tty->client; ! struct winsize ws; ! u_int sx, sy; if (ioctl(tty->fd, TIOCGWINSZ, &ws) != -1) { sx = ws.ws_col; *************** *** 139,145 **** sx = 80; sy = 24; } ! log_debug("%s: %s now %ux%u", __func__, tty->path, sx, sy); if (!tty_set_size(tty, sx, sy)) return (0); tty_invalidate(tty); --- 136,143 ---- sx = 80; sy = 24; } ! log_debug("%s: %s now %ux%u", __func__, c->name, sx, sy); ! if (!tty_set_size(tty, sx, sy)) return (0); tty_invalidate(tty); *************** *** 160,172 **** tty_read_callback(__unused int fd, __unused short events, void *data) { struct tty *tty = data; size_t size = EVBUFFER_LENGTH(tty->in); int nread; nread = evbuffer_read(tty->in, tty->fd, -1); if (nread == -1) return; ! log_debug("%s: read %d bytes (already %zu)", tty->path, nread, size); while (tty_keys_next(tty)) ; --- 158,171 ---- tty_read_callback(__unused int fd, __unused short events, void *data) { struct tty *tty = data; + struct client *c = tty->client; size_t size = EVBUFFER_LENGTH(tty->in); int nread; nread = evbuffer_read(tty->in, tty->fd, -1); if (nread == -1) return; ! log_debug("%s: read %d bytes (already %zu)", c->name, nread, size); while (tty_keys_next(tty)) ; *************** *** 176,188 **** tty_write_callback(__unused int fd, __unused short events, void *data) { struct tty *tty = data; size_t size = EVBUFFER_LENGTH(tty->out); int nwrite; nwrite = evbuffer_write(tty->out, tty->fd); if (nwrite == -1) return; ! log_debug("%s: wrote %d bytes (of %zu)", tty->path, nwrite, size); if (EVBUFFER_LENGTH(tty->out) != 0) event_add(&tty->event_out, NULL); --- 175,188 ---- tty_write_callback(__unused int fd, __unused short events, void *data) { struct tty *tty = data; + struct client *c = tty->client; size_t size = EVBUFFER_LENGTH(tty->out); int nwrite; nwrite = evbuffer_write(tty->out, tty->fd); if (nwrite == -1) return; ! log_debug("%s: wrote %d bytes (of %zu)", c->name, nwrite, size); if (EVBUFFER_LENGTH(tty->out) != 0) event_add(&tty->event_out, NULL); *************** *** 351,357 **** tty_close(tty); free(tty->ccolour); - free(tty->path); free(tty->term_name); } --- 351,356 ---- *************** *** 424,431 **** static void tty_add(struct tty *tty, const char *buf, size_t len) { evbuffer_add(tty->out, buf, len); ! log_debug("%s: %.*s", tty->path, (int)len, (const char *)buf); if (tty_log_fd != -1) write(tty_log_fd, buf, len); --- 423,432 ---- static void tty_add(struct tty *tty, const char *buf, size_t len) { + struct client *c = tty->client; + evbuffer_add(tty->out, buf, len); ! log_debug("%s: %.*s", c->name, (int)len, (const char *)buf); if (tty_log_fd != -1) write(tty_log_fd, buf, len);