summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorNed T. Crigler <crigler@users.sourceforge.net>2014-08-03 22:24:47 -0700
committerNed T. Crigler <crigler@users.sourceforge.net>2014-08-04 12:46:30 -0700
commitc7b68ae3fa3f8b367b0b8201e5ab3d0323363ee4 (patch)
treed90d15d8554563ed84eb6a9f32e604245a97930d /main.c
parent8527d8e8765d2e19f118f915cec3301b1c6cf5ea (diff)
Add dtach -N.
dtach -N is similar to dtach -n, except dtach will not daemonize. Based on patches by Ciprian Dorin Craciun and Frank Hunleth.
Diffstat (limited to 'main.c')
-rw-r--r--main.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/main.c b/main.c
index ade242a..4bd55c3 100644
--- a/main.c
+++ b/main.c
@@ -55,6 +55,7 @@ usage()
" dtach -A <socket> <options> <command...>\n"
" dtach -c <socket> <options> <command...>\n"
" dtach -n <socket> <options> <command...>\n"
+ " dtach -N <socket> <options> <command...>\n"
"Modes:\n"
" -a\t\tAttach to the specified socket.\n"
" -A\t\tAttach to the specified socket, or create it if it\n"
@@ -62,6 +63,9 @@ usage()
" -c\t\tCreate a new socket and run the specified command.\n"
" -n\t\tCreate a new socket and run the specified command "
"detached.\n"
+ " -N\t\tCreate a new socket and run the specified command "
+ "detached,\n"
+ "\t\t and have dtach run in the foreground.\n"
"Options:\n"
" -e <char>\tSet the detach character to <char>, defaults "
"to ^\\.\n"
@@ -102,7 +106,7 @@ main(int argc, char **argv)
if (mode == '?')
usage();
else if (mode != 'a' && mode != 'c' && mode != 'n' &&
- mode != 'A')
+ mode != 'A' && mode != 'N')
{
printf("%s: Invalid mode '-%c'\n", progname, mode);
printf("Try '%s --help' for more information.\n",
@@ -215,7 +219,7 @@ main(int argc, char **argv)
dont_have_tty = 1;
}
- if (dont_have_tty && mode != 'n')
+ if (dont_have_tty && mode != 'n' && mode != 'N')
{
printf("%s: Attaching to a session requires a terminal.\n",
progname);
@@ -235,10 +239,12 @@ main(int argc, char **argv)
return attach_main(0);
}
else if (mode == 'n')
- return master_main(argv, 0);
+ return master_main(argv, 0, 0);
+ else if (mode == 'N')
+ return master_main(argv, 0, 1);
else if (mode == 'c')
{
- if (master_main(argv, 1) != 0)
+ if (master_main(argv, 1, 0) != 0)
return 1;
return attach_main(0);
}
@@ -252,7 +258,7 @@ main(int argc, char **argv)
{
if (errno == ECONNREFUSED)
unlink(sockname);
- if (master_main(argv, 1) != 0)
+ if (master_main(argv, 1, 0) != 0)
return 1;
}
return attach_main(0);