From d01e7aac89fefff31e668ac2d668c84c345b9e67 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 10 May 2020 16:52:46 +0100 Subject: Add a -D flag to ask tmux not to daemonize, useful both for running a debugger (lldb does not have follow-fork-mode) and for running with a managed supervisor init system. GitHub issue 2190. --- server-client.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index 794cb41e..c9250491 100644 --- a/server-client.c +++ b/server-client.c @@ -236,11 +236,22 @@ server_client_create(int fd) int server_client_open(struct client *c, char **cause) { + const char *ttynam = _PATH_TTY; + if (c->flags & CLIENT_CONTROL) return (0); - if (strcmp(c->ttyname, "/dev/tty") == 0) { - *cause = xstrdup("can't use /dev/tty"); + if (strcmp(c->ttyname, ttynam) || + ((isatty(STDIN_FILENO) && + (ttynam = ttyname(STDIN_FILENO)) != NULL && + strcmp(c->ttyname, ttynam) == 0) || + (isatty(STDOUT_FILENO) && + (ttynam = ttyname(STDOUT_FILENO)) != NULL && + strcmp(c->ttyname, ttynam) == 0) || + (isatty(STDERR_FILENO) && + (ttynam = ttyname(STDERR_FILENO)) != NULL && + strcmp(c->ttyname, ttynam) == 0))) { + xasprintf(cause, "can't use %s", c->ttyname); return (-1); } -- cgit