diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-08-14 21:23:20 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-08-14 21:23:20 +0000 |
commit | e2a18894b34e3651feecba1dd43c4f05c9566509 (patch) | |
tree | a15c5d4ff41e637982452222ede90d433dbc10a6 /tty.c | |
parent | 0714e411488e01273729bc0801e197a8f64d5540 (diff) | |
download | rtmux-e2a18894b34e3651feecba1dd43c4f05c9566509.tar.gz rtmux-e2a18894b34e3651feecba1dd43c4f05c9566509.tar.bz2 rtmux-e2a18894b34e3651feecba1dd43c4f05c9566509.zip |
Sync OpenBSD patchset 246:
Have the client pass its stdin fd to the server when identifying itself and
have the server use that rather than reopening the tty. If the fd isn't given,
use the old behaviour (so no need for a version change).
This allows tmux to be used as the shell, so also change so that when working
out the command to execute if default-command is empty (the default), tmux will
try not execute itself.
Diffstat (limited to 'tty.c')
-rw-r--r-- | tty.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -1,4 +1,4 @@ -/* $Id: tty.c,v 1.124 2009-08-14 21:20:01 tcunha Exp $ */ +/* $Id: tty.c,v 1.125 2009-08-14 21:23:20 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -45,9 +45,11 @@ void tty_cell(struct tty *, const struct grid_cell *, const struct grid_utf8 *); void -tty_init(struct tty *tty, char *path, char *term) +tty_init(struct tty *tty, int fd, char *path, char *term) { tty->path = xstrdup(path); + tty->fd = fd; + if (term == NULL || *term == '\0') tty->termname = xstrdup("unknown"); else @@ -59,12 +61,14 @@ tty_init(struct tty *tty, char *path, char *term) int tty_open(struct tty *tty, const char *overrides, char **cause) { - int mode; + int mode; - tty->fd = open(tty->path, O_RDWR|O_NONBLOCK); if (tty->fd == -1) { - xasprintf(cause, "%s: %s", tty->path, strerror(errno)); - return (-1); + tty->fd = open(tty->path, O_RDWR|O_NONBLOCK); + if (tty->fd == -1) { + xasprintf(cause, "%s: %s", tty->path, strerror(errno)); + return (-1); + } } if ((mode = fcntl(tty->fd, F_GETFL)) == -1) |