summaryrefslogtreecommitdiffstats
path: root/cmd-new-session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-09-16 12:36:28 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-09-16 12:36:28 +0000
commit15b643fc119221658ca3e9c6718eeb88ffcbe47a (patch)
tree21c2d4ebd4565117a9a4d9ed7c98f84326849f07 /cmd-new-session.c
parent150fba5ecdb3fedd8aed71ee65fb8cc6b0354070 (diff)
Sync from OpenBSD:
== 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. == This should fix problems caused by glibc's broken ttydefaults.h file.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r--cmd-new-session.c51
1 files changed, 8 insertions, 43 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c
index 148404ed..08b2029d 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-new-session.c,v 1.65 2009-09-15 23:52:30 tcunha Exp $ */
+/* $Id: cmd-new-session.c,v 1.66 2009-09-16 12:36:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -24,18 +24,6 @@
#include "tmux.h"
-#ifdef HAVE_TTYDEFAULTS_H
-#ifdef HAVE_TTYDEFCHARS
-#define TTYDEFCHARS
-#endif
-#include <sys/ttydefaults.h>
-#else
-#ifndef OXTABS
-#define OXTABS 0
-#endif
-#include "compat/ttydefaults.h"
-#endif
-
/*
* Create a new session and attach to the current terminal unless -d is given.
*/
@@ -126,7 +114,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;
@@ -161,8 +149,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
@@ -172,32 +160,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");
- } else {
-#ifdef HAVE_TTYDEFCHARS
- memcpy(tio.c_cc, ttydefchars, sizeof tio.c_cc);
-#else
- memset(tio.c_cc, _POSIX_VDISABLE, sizeof tio.c_cc);
- tio.c_cc[VINTR] = CINTR;
- tio.c_cc[VQUIT] = CQUIT;
- tio.c_cc[VKILL] = CKILL;
- tio.c_cc[VEOF] = CEOF;
- tio.c_cc[VSTART] = CSTART;
- tio.c_cc[VSTOP] = CSTOP;
- tio.c_cc[VSUSP] = CSUSP;
- tio.c_cc[VEOL] = CEOL;
- tio.c_cc[VREPRINT] = CREPRINT;
- tio.c_cc[VDISCARD] = CDISCARD;
- tio.c_cc[VWERASE] = CWERASE;
- tio.c_cc[VLNEXT] = CLNEXT;
-#endif
- }
- 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 = &tio;
+ } else
+ tiop = NULL;
/* Open the terminal if necessary. */
if (!detached && ctx->cmdclient != NULL) {
@@ -254,7 +219,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);