summaryrefslogtreecommitdiffstats
path: root/cmd-new-session.c
diff options
context:
space:
mode:
authornicm <nicm>2015-06-04 23:27:51 +0000
committernicm <nicm>2015-06-04 23:27:51 +0000
commit6b2129696fbefe44d0adce1f2a11b4ae477cd07e (patch)
treed204c7289caf70e18ea66fe75a7e3a0e668fd844 /cmd-new-session.c
parentdc0d34e13792ff14b5c02fac01af013dfe111c83 (diff)
Move the nested check from client to server and compare the client tty
name to all the pane pty names instead of comparing socket paths. This means that "new -d" will work without unsetting $TMUX.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r--cmd-new-session.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c
index 9c767489..0fb849e2 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -41,7 +41,7 @@ const struct cmd_entry cmd_new_session_entry = {
"[-AdDP] [-c start-directory] [-F format] [-n window-name] "
"[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "
"[-y height] [command]",
- CMD_STARTSERVER|CMD_CANTNEST,
+ CMD_STARTSERVER,
cmd_new_session_exec
};
@@ -145,15 +145,20 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
}
/*
- * Save the termios settings, part of which is used for new windows in
- * this session.
+ * If this is a new client, check for nesting and 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
- * before opening the terminal as that calls tcsetattr() to prepare for
- * tmux taking over.
+ * tcgetattr() is used rather than using tty.tio since if the client is
+ * detached, tty_open won't be called. It must be done before opening
+ * the terminal as that calls tcsetattr() to prepare for tmux taking
+ * over.
*/
if (!detached && !already_attached && c->tty.fd != -1) {
+ if (server_client_check_nested(cmdq->client)) {
+ cmdq_error(cmdq, "sessions should be nested with care, "
+ "unset $TMUX to force");
+ return (CMD_RETURN_ERROR);
+ }
if (tcgetattr(c->tty.fd, &tio) != 0)
fatal("tcgetattr failed");
tiop = &tio;