=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-new-session.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- src/usr.bin/tmux/cmd-new-session.c 2009/08/19 14:32:15 1.14 +++ src/usr.bin/tmux/cmd-new-session.c 2009/08/21 11:36:08 1.15 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.14 2009/08/19 14:32:15 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.15 2009/08/21 11:36:08 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -149,6 +149,27 @@ if (ctx->cmdclient == NULL && ctx->curclient == NULL) detached = 1; + /* + * Fill in the termios settings used for new windows in this session; + * if there is a command client, use the control characters from it. + * + * This is read again with tcgetattr() rather than using tty.tio as if + * detached, tty_open won't be called. Because of this, it must be done + * before opening the terminal as that calls tcsetattr() to prepare for + * tmux taking over. + */ + if (ctx->cmdclient != NULL && ctx->cmdclient->tty.fd != -1) { + if (tcgetattr(ctx->cmdclient->tty.fd, &tio) != 0) + fatal("tcgetattr failed"); + } else + memcpy(tio.c_cc, ttydefchars, sizeof tio.c_cc); + tio.c_iflag = TTYDEF_IFLAG; + tio.c_oflag = TTYDEF_OFLAG; + tio.c_lflag = TTYDEF_LFLAG; + tio.c_cflag = TTYDEF_CFLAG; + cfsetispeed(&tio, TTYDEF_SPEED); + cfsetospeed(&tio, TTYDEF_SPEED); + /* Open the terminal if necessary. */ if (!detached && ctx->cmdclient != NULL) { if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) { @@ -198,22 +219,6 @@ update = options_get_string(&global_s_options, "update-environment"); if (ctx->cmdclient != NULL) environ_update(update, &ctx->cmdclient->environ, &env); - - /* - * Fill in the termios settings used for new windows in this session; - * if there is a command client, use the control characters from it. - */ - if (ctx->cmdclient != NULL && ctx->cmdclient->tty.fd != -1) { - if (tcgetattr(ctx->cmdclient->tty.fd, &tio) != 0) - fatal("tcgetattr failed"); - } else - memcpy(tio.c_cc, ttydefchars, sizeof tio.c_cc); - tio.c_iflag = TTYDEF_IFLAG; - tio.c_oflag = TTYDEF_OFLAG; - tio.c_lflag = TTYDEF_LFLAG; - tio.c_cflag = TTYDEF_CFLAG; - cfsetispeed(&tio, TTYDEF_SPEED); - cfsetospeed(&tio, TTYDEF_SPEED); /* Create the new session. */ idx = -1 - options_get_number(&global_s_options, "base-index");