aboutsummaryrefslogtreecommitdiff
path: root/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-08-11 21:28:11 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-08-11 21:28:11 +0000
commit4310282a4c52f1885ae2eb80b106c9c03564a0b8 (patch)
tree21099e70cdd49e4dc08084bbd758e64677728774 /tty.c
parent4ec8ade11c23eec4b652cdd7ea47ddf346b7be93 (diff)
downloadrtmux-4310282a4c52f1885ae2eb80b106c9c03564a0b8.tar.gz
rtmux-4310282a4c52f1885ae2eb80b106c9c03564a0b8.tar.bz2
rtmux-4310282a4c52f1885ae2eb80b106c9c03564a0b8.zip
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.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/tty.c b/tty.c
index 1da0c2ff..d850347a 100644
--- a/tty.c
+++ b/tty.c
@@ -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)