summaryrefslogtreecommitdiffstats
path: root/cmd-new-session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-09-16 12:35:04 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-09-16 12:35:04 +0000
commit5c60162e3c4f8ac9deede6c0fb5a21930d92e3b4 (patch)
tree16e91d61eed65cf74d3987cf9b7cd08ffea48288 /cmd-new-session.c
parenta6dd9e8e7eb0d7734b0905a97f6e8b0087a2e09c (diff)
Rather than constructing an entire termios struct from ttydefaults.h, just let
forkpty do it and then alter the bits that should be changed after fork. A little neater and more portable.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r--cmd-new-session.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c
index df1ec45c..467fa879 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -21,9 +21,6 @@
#include <string.h>
#include <termios.h>
-#define TTYDEFCHARS
-#include <sys/ttydefaults.h>
-
#include "tmux.h"
/*
@@ -116,7 +113,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
struct session *s;
struct window *w;
struct environ env;
- struct termios tio;
+ struct termios tio, *tiop;
const char *update;
char *overrides, *cmd, *cwd, *cause;
int detached, idx;
@@ -151,8 +148,8 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
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.
+ * Save the termios settings, part of which is used for new windows in
+ * this session.
*
* 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
@@ -162,15 +159,9 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
if (ctx->cmdclient != NULL && ctx->cmdclient->tty.fd != -1) {
if (tcgetattr(ctx->cmdclient->tty.fd, &tio) != 0)
fatal("tcgetattr failed");
+ tiop = &tio;
} else
- memcpy(tio.c_cc, ttydefchars, sizeof tio.c_cc);
- tio.c_cc[VERASE] = '\177';
- 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);
+ tiop = NULL;
/* Open the terminal if necessary. */
if (!detached && ctx->cmdclient != NULL) {
@@ -227,7 +218,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
/* Create the new session. */
idx = -1 - options_get_number(&global_s_options, "base-index");
s = session_create(
- data->newname, cmd, cwd, &env, &tio, idx, sx, sy, &cause);
+ data->newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause);
if (s == NULL) {
ctx->error(ctx, "create session failed: %s", cause);
xfree(cause);