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

9
tmux.c
View File

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