aboutsummaryrefslogtreecommitdiff
path: root/cmd-new-session.c
diff options
context:
space:
mode:
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;