From bf8ca5f019fa9fd585a7480a3d4198719369df92 Mon Sep 17 00:00:00 2001 From: Peiyuan Song Date: Wed, 20 Jan 2021 13:33:52 +0900 Subject: 47840: make zpty module work on Cygwin --- Src/Modules/zpty.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Src') 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 +#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)); -- cgit 1.4.1