From dceb6a15d04a2b2e050ab41816d0df3fe224b416 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 16 May 2020 16:07:55 +0000 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. --- tmux.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tmux.c') diff --git a/tmux.c b/tmux.c index 137c7eeb..cfc84cd0 100644 --- a/tmux.c +++ b/tmux.c @@ -57,7 +57,7 @@ static __dead void usage(void) { fprintf(stderr, - "usage: %s [-2CluvV] [-c shell-command] [-f file] [-L socket-name]\n" + "usage: %s [-2CDluvV] [-c shell-command] [-f file] [-L socket-name]\n" " [-S socket-path] [-T features] [command [flags]]\n", getprogname()); exit(1); @@ -336,7 +336,7 @@ main(int argc, char **argv) if (**argv == '-') flags = CLIENT_LOGIN; - while ((opt = getopt(argc, argv, "2c:Cdf:lL:qS:T:uUvV")) != -1) { + while ((opt = getopt(argc, argv, "2c:CDdf:lL:qS:T:uUvV")) != -1) { switch (opt) { case '2': tty_add_features(&feat, "256", ":,"); @@ -344,6 +344,9 @@ main(int argc, char **argv) case 'c': shell_command = optarg; break; + case 'D': + flags |= CLIENT_NOFORK; + break; case 'C': if (flags & CLIENT_CONTROL) flags |= CLIENT_CONTROLCONTROL; @@ -387,6 +390,8 @@ main(int argc, char **argv) if (shell_command != NULL && argc != 0) usage(); + if ((flags & CLIENT_NOFORK) && argc != 0) + usage(); if ((ptm_fd = getptmfd()) == -1) err(1, "getptmfd"); -- cgit v1.2.3