mirror of
https://github.com/tmux/tmux.git
synced 2025-12-22 15:36:06 +00:00
Pass terminal data on socket on Cygwin platforms
On Cygwin and MSYS2 use a controlling pty for the server client handler instead of passing a file descriptor over the socket which is not possible on Cygwin platforms. Attach an event to STDIN on the client, passing data from it to the server and attach an event to the pty out_fd on the server client handler and pass data from it to the client. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
39
tty.c
39
tty.c
@@ -250,6 +250,11 @@ tty_write_callback(__unused int fd, __unused short events, void *data)
|
||||
struct client *c = tty->client;
|
||||
size_t size = EVBUFFER_LENGTH(tty->out);
|
||||
int nwrite;
|
||||
#ifdef TTY_OVER_SOCKET
|
||||
enum msgtype msg = MSG_TTY_READ;
|
||||
|
||||
proc_send(c->peer, msg, -1, EVBUFFER_DATA(tty->out), size);
|
||||
#endif
|
||||
|
||||
nwrite = evbuffer_write(tty->out, c->fd);
|
||||
if (nwrite == -1)
|
||||
@@ -304,6 +309,40 @@ tty_open(struct tty *tty, char **cause)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef TTY_OVER_SOCKET
|
||||
static struct tmuxpeer *client_peer;
|
||||
|
||||
static void
|
||||
tty_stdin_socket_callback(int fd, __unused short events, void *data)
|
||||
{
|
||||
struct tty *tty = data;
|
||||
int nread;
|
||||
enum msgtype msg = MSG_TTY_WRITE;
|
||||
|
||||
nread = evbuffer_read(tty->in, fd, -1);
|
||||
if (nread == 0 || nread == -1) {
|
||||
event_del(&tty->event_in);
|
||||
return;
|
||||
}
|
||||
|
||||
proc_send(client_peer, msg, -1, EVBUFFER_DATA(tty->in), nread);
|
||||
}
|
||||
|
||||
int
|
||||
tty_attach_stdin_to_socket(struct tty *tty, struct tmuxpeer *peer)
|
||||
{
|
||||
client_peer = peer;
|
||||
|
||||
event_set(&tty->event_in, STDIN_FILENO, EV_PERSIST|EV_READ,
|
||||
tty_stdin_socket_callback, tty);
|
||||
tty->in = evbuffer_new();
|
||||
if (tty->in == NULL)
|
||||
fatal("out of memory");
|
||||
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
tty_start_timer_callback(__unused int fd, __unused short events, void *data)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user