From: Peiyuan Song <squallatf@gmail.com>
To: zsh-workers@zsh.org
Subject: [PATCH v3] Make zpty module work in the cygwin and msys2
Date: Mon, 18 Jan 2021 10:28:46 +0800 [thread overview]
Message-ID: <CAE0YKFtwinQfxxnY1x=YGPg+cxzjA0=d+W0OW8S6SQH6mYqgjQ@mail.gmail.com> (raw)
cygwin have /dev/ptmx, need defined `_GNU_SOURCE 1` to use it, but
configure check /dev/ptmx is usable only defined it for linux.
Another probleam is cygwin upstream have an issue
https://cygwin.com/pipermail/cygwin-developers/2021-January/012030.html,
because of that issue, movefd will broken the fd opened by
posix_openpt, so that we mast disable movefd in zpty until cygwin
fix that issue.
v3 change: remove duplicate the code for check_fd_table, use
addmodulefd, assume cygwin upstream issue will be fixed in version
3.2.0
---
Src/Modules/zpty.c | 11 +++++++++++
configure.ac | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
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));
diff --git a/configure.ac b/configure.ac
index 549cae3d6..16dafac05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2460,7 +2460,7 @@ if test x$ac_cv_have_dev_ptmx = xyes -o
x$ac_cv_func_posix_openpt = xyes && \
test x$ac_cv_func_ptsname = xyes; then
AC_CACHE_CHECK([if /dev/ptmx is usable],
ac_cv_use_dev_ptmx,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef __linux
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if defined(__linux) ||
defined(__CYGWIN__)
#define _GNU_SOURCE 1
#endif
#include <stdlib.h>
--
2.30.0.windows.2
next reply other threads:[~2021-01-18 2:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 2:28 Peiyuan Song [this message]
2021-01-18 5:43 ` Jun T
2021-01-18 7:17 ` Bart Schaefer
2021-01-18 10:56 ` Jun T
2021-01-19 8:44 ` Jun T
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAE0YKFtwinQfxxnY1x=YGPg+cxzjA0=d+W0OW8S6SQH6mYqgjQ@mail.gmail.com' \
--to=squallatf@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).