diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-09-16 12:35:05 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-09-16 12:35:05 +0000 |
commit | a52b2186877eb82197db226ad6589a8743b6c299 (patch) | |
tree | 354d58b6c46b7b3d048161ae5c84f5a128525fd0 /usr.bin/tmux/cmd-new-session.c | |
parent | 040854e58efbc3bb4fcf77070c0857e4ba32bd5a (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 'usr.bin/tmux/cmd-new-session.c')
-rw-r--r-- | usr.bin/tmux/cmd-new-session.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index 77322fabd68..adba608fcf8 100644 --- a/usr.bin/tmux/cmd-new-session.c +++ b/usr.bin/tmux/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.18 2009/09/15 07:45:16 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.19 2009/09/16 12:35:04 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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); |