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:
nicm
2020-05-16 16:07:55 +00:00
parent 126bacb473
commit dceb6a15d0
7 changed files with 73 additions and 25 deletions

View File

@@ -238,11 +238,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) == 0||
((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);
}