summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/client.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2012-06-18 13:16:42 +0000
committernicm <nicm@openbsd.org>2012-06-18 13:16:42 +0000
commit90896992596b3ed328f806012b5b6bcedafb12da (patch)
tree710be24359a9443ba43594518b4a849b071c6c44 /usr.bin/tmux/client.c
parentClarify description of -W. Noted by Steve.McClellan at radisys com, ok jmc (diff)
downloadwireguard-openbsd-90896992596b3ed328f806012b5b6bcedafb12da.tar.xz
wireguard-openbsd-90896992596b3ed328f806012b5b6bcedafb12da.zip
Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to integrate with other terminal emulators and should allow some other things to be made simpler later. More to come so doesn't do much yet and deliberately not documented.
Diffstat (limited to 'usr.bin/tmux/client.c')
-rw-r--r--usr.bin/tmux/client.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c
index 1e6338d560e..f76145c6688 100644
--- a/usr.bin/tmux/client.c
+++ b/usr.bin/tmux/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.55 2012/05/25 08:28:10 nicm Exp $ */
+/* $OpenBSD: client.c,v 1.56 2012/06/18 13:16:42 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -169,6 +169,7 @@ client_main(int argc, char **argv, int flags)
pid_t ppid;
enum msgtype msg;
char *cause;
+ struct termios tio, saved_tio;
/* Set up the initial command. */
cmdflags = 0;
@@ -233,6 +234,23 @@ client_main(int argc, char **argv, int flags)
setblocking(STDIN_FILENO, 0);
event_set(&client_stdin, STDIN_FILENO, EV_READ|EV_PERSIST,
client_stdin_callback, NULL);
+ if (flags & IDENTIFY_TERMIOS) {
+ if (tcgetattr(STDIN_FILENO, &saved_tio) != 0) {
+ fprintf(stderr, "tcgetattr failed: %s\n",
+ strerror(errno));
+ return (1);
+ }
+ cfmakeraw(&tio);
+ tio.c_iflag = ICRNL|IXANY;
+ tio.c_oflag = OPOST|ONLCR;
+ tio.c_lflag = NOKERNINFO;
+ tio.c_cflag = CREAD|CS8|HUPCL;
+ tio.c_cc[VMIN] = 1;
+ tio.c_cc[VTIME] = 0;
+ cfsetispeed(&tio, cfgetispeed(&saved_tio));
+ cfsetospeed(&tio, cfgetospeed(&saved_tio));
+ tcsetattr(STDIN_FILENO, TCSANOW, &tio);
+ }
/* Establish signal handlers. */
set_signals(client_signal);
@@ -273,7 +291,8 @@ client_main(int argc, char **argv, int flags)
ppid = getppid();
if (client_exittype == MSG_DETACHKILL && ppid > 1)
kill(ppid, SIGHUP);
- }
+ } else if (flags & IDENTIFY_TERMIOS)
+ tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio);
setblocking(STDIN_FILENO, 1);
return (client_exitval);
}
@@ -513,6 +532,12 @@ client_dispatch_wait(void *data)
shell_exec(shelldata.shell, shellcmd);
/* NOTREACHED */
+ case MSG_DETACH:
+ client_write_server(MSG_EXITING, NULL, 0);
+ break;
+ case MSG_EXITED:
+ imsg_free(&imsg);
+ return (-1);
default:
fatalx("unexpected message");
}