Are you sure ECHOPRT 0x20 is right on Cygwin? Maybe it should be 0 to
leave it out if it isn't supported?

Also some other minor tweaks.

diff --git a/client.c b/client.c
index 691ace3..b9e3b30 100644
--- a/client.c
+++ b/client.c
@@ -328,8 +328,13 @@ client_send_identify(int flags)
            strlcpy(data.term, term, sizeof data.term) >= sizeof data.term)
                *data.term = '\0';
 
+#ifdef __CYGWIN__
+       snprintf(&data.ttyname, sizeof data.ttyname, "%s",
+           ttyname(STDIN_FILENO));
+#else
        if ((fd = dup(STDIN_FILENO)) == -1)
                fatal("dup failed");
+#endif
        imsg_compose(&client_ibuf,
            MSG_IDENTIFY, PROTOCOL_VERSION, -1, fd, &data, sizeof data);
        client_update_event();
diff --git a/compat.h b/compat.h
index d397379..b84ff40 100644
--- a/compat.h
+++ b/compat.h
@@ -30,6 +30,10 @@
 #define __packed __attribute__ ((__packed__))
 #endif
 
+#ifndef ECHOPRT
+#define ECHOPRT 0
+#endif
+
 #ifndef HAVE_BSD_TYPES
 typedef uint8_t u_int8_t;
 typedef uint16_t u_int16_t;
@@ -210,6 +214,7 @@ int          daemon(int, int);
 
 #ifndef HAVE_B64_NTOP
 /* b64_ntop.c */
+#undef b64_ntop /* for Cygwin */
 int             b64_ntop(const char *, size_t, char *, size_t);
 #endif
 
diff --git a/server-client.c b/server-client.c
index 01616cb..5923eb0 100644
--- a/server-client.c
+++ b/server-client.c
@@ -825,9 +825,12 @@ server_client_msg_dispatch(struct client *c)
                case MSG_IDENTIFY:
                        if (datalen != sizeof identifydata)
                                fatalx("bad MSG_IDENTIFY size");
+                       memcpy(&identifydata, imsg.data, sizeof identifydata);
+#ifdef __CYGWIN__
+                       imsg.fd = open(identifydata.ttyname, O_RDWR|O_NOCTTY);
+#endif
                        if (imsg.fd == -1)
                                fatalx("MSG_IDENTIFY missing fd");
-                       memcpy(&identifydata, imsg.data, sizeof identifydata);
 
                        server_client_msg_identify(c, &identifydata, imsg.fd);
                        break;
diff --git a/tmux.h b/tmux.h
index 5dd86d3..03245b5 100644
--- a/tmux.h
+++ b/tmux.h
@@ -471,6 +471,10 @@ struct msg_identify_data {
 
        char            term[TERMINAL_LENGTH];
 
+#ifdef __CYGWIN__
+       char            ttyname[TTY_NAME_MAX];
+#endif
+
 #define IDENTIFY_UTF8 0x1
 #define IDENTIFY_256COLOURS 0x2
 /* 0x4 unused */



On Sun, Jun 02, 2013 at 04:21:02PM -0500, J Raynor wrote:
> I've attached a new patch that puts the msg_identify_data change in an
> ifdef.  Also, in compat.h, I moved the "undef b64_ntop" for cygwin
> into the "ifndef HAVE_B64_NTOP" check so that if cygwin ever gets a
> working b64_ntop tmux will continue to compile.
> 
> If I do "tmux new </dev/null" then tmux doesn't start and doesn't
> print out an error.  Using -v flags, I see that the server gets a -1
> when trying to open the terminal.  This is because
> ttyname(STDIN_FILENO) in client.c doesn't get something valid, so it
> passes something worthless to the server.  Should the "ifdef
> __CYGWIN__" check in client.c do isatty before passing the ttyname?



------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to