summaryrefslogtreecommitdiffstats
path: root/cmd-new-session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-08-21 11:36:08 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-08-21 11:36:08 +0000
commit915a1913e19dd254689f51bc228686f83f2d77ee (patch)
tree43d1314ad99c0b81d9f69798e24953970c25979e /cmd-new-session.c
parent65ac8e9f0c852cbf436243258c0c1878b20c3c87 (diff)
Move reading termios settings to before tty_open alters them, and expand the
comment.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r--cmd-new-session.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c
index bffdb2b8..73698d24 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -149,6 +149,27 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
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)) {
@@ -199,22 +220,6 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
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");
s = session_create(