about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeiyuan Song <squallatf@gmail.com>2021-01-20 13:33:52 +0900
committerJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2021-01-20 13:33:52 +0900
commitbf8ca5f019fa9fd585a7480a3d4198719369df92 (patch)
tree12fc5dba7c859ff280c8df7b617fea19d72f5696 /Src
parentce0660b7ba283e3208db28a8763796816a587259 (diff)
downloadzsh-bf8ca5f019fa9fd585a7480a3d4198719369df92.tar.gz
zsh-bf8ca5f019fa9fd585a7480a3d4198719369df92.tar.xz
zsh-bf8ca5f019fa9fd585a7480a3d4198719369df92.zip
47840: make zpty module work on Cygwin
Diffstat (limited to 'Src')
-rw-r--r--Src/Modules/zpty.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c
index 45fd15ee0..dfd2a2a7a 100644
--- a/Src/Modules/zpty.c
+++ b/Src/Modules/zpty.c
@@ -30,6 +30,13 @@
 #include "zpty.mdh"
 #include "zpty.pro"
 
+#ifdef __CYGWIN__
+#include <cygwin/version.h>
+#if defined(CYGWIN_VERSION_DLL_MAJOR) && CYGWIN_VERSION_DLL_MAJOR<3002
+#define USE_CYGWIN_FIX 1
+#endif
+#endif
+
 /* The number of bytes we normally read when given no pattern and the
  * upper bound on the number of bytes we read (even if we are give a
  * pattern). */
@@ -428,6 +435,7 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock)
 	mypid = 0; /* trick to ensure we _exit() */
 	zexit(lastval, ZEXIT_NORMAL);
     }
+#ifndef USE_CYGWIN_FIX
     master = movefd(master);
     if (master == -1) {
 	zerrnam(nam, "cannot duplicate fd %d: %e", master, errno);
@@ -435,6 +443,9 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock)
 	ineval = oineval;
 	return 1;
     }
+#else
+    addmodulefd(master, FDT_INTERNAL);
+#endif
 
     p = (Ptycmd) zalloc(sizeof(*p));