summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/session.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2009-09-16 12:35:04 +0000
committernicm <nicm@openbsd.org>2009-09-16 12:35:04 +0000
commitf58d72627563d26eac4c859fa1d6f3de180f34c1 (patch)
treecf5494ae38a33e550a559e751c69099366b59644 /usr.bin/tmux/session.c
parentstyle: in pf_test_state_other, fix indentation, kill excessive newlines, (diff)
downloadwireguard-openbsd-f58d72627563d26eac4c859fa1d6f3de180f34c1.tar.xz
wireguard-openbsd-f58d72627563d26eac4c859fa1d6f3de180f34c1.zip
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/session.c')
-rw-r--r--usr.bin/tmux/session.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/tmux/session.c b/usr.bin/tmux/session.c
index 6fae595e32e..e4ba1a38167 100644
--- a/usr.bin/tmux/session.c
+++ b/usr.bin/tmux/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.7 2009/09/07 21:01:50 nicm Exp $ */
+/* $OpenBSD: session.c,v 1.8 2009/09/16 12:35:04 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -139,7 +139,12 @@ session_create(const char *name, const char *cmd, const char *cwd,
environ_init(&s->environ);
if (env != NULL)
environ_copy(env, &s->environ);
- memcpy(&s->tio, tio, sizeof s->tio);
+
+ s->tio = NULL;
+ if (tio != NULL) {
+ s->tio = xmalloc(sizeof *s->tio);
+ memcpy(s->tio, tio, sizeof *s->tio);
+ }
s->sx = sx;
s->sy = sy;
@@ -182,6 +187,9 @@ session_destroy(struct session *s)
while (!ARRAY_EMPTY(&sessions) && ARRAY_LAST(&sessions) == NULL)
ARRAY_TRUNC(&sessions, 1);
+ if (s->tio != NULL)
+ xfree(s->tio);
+
session_alert_cancel(s, NULL);
environ_free(&s->environ);
options_free(&s->options);
@@ -237,7 +245,7 @@ session_new(struct session *s,
hlimit = options_get_number(&s->options, "history-limit");
w = window_create(
- name, cmd, shell, cwd, &env, &s->tio, s->sx, s->sy, hlimit, cause);
+ name, cmd, shell, cwd, &env, s->tio, s->sx, s->sy, hlimit, cause);
if (w == NULL) {
environ_free(&env);
return (NULL);