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.
This commit is contained in:
Nicholas Marriott
2020-05-10 16:52:46 +01:00
parent 5fa377d927
commit d01e7aac89
7 changed files with 73 additions and 25 deletions

View File

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