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.
This commit is contained in:
Nicholas Marriott
2009-09-16 12:36:28 +00:00
parent 150fba5ecd
commit 15b643fc11
8 changed files with 37 additions and 205 deletions

View File

@ -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);