Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Hang in E01 due to zpty on OpenBSD
- X-seq: zsh-workers 49984
- From: Jun T <takimoto-j@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Hang in E01 due to zpty on OpenBSD
- Date: Mon, 4 Apr 2022 17:34:09 +0900
- Archived-at: <https://zsh.org/workers/49984>
- In-reply-to: <YkpqyANtIznaB1tC@CptOrmolo.darkstar>
- List-id: <zsh-workers.zsh.org>
- References: <YkoUwETgsrrqDeZN@CptOrmolo.darkstar> <CAH+w=7ba1fo9BdNurD9TH5MjuyYRk=-xJ0ioXo8aTt_ZCKEhLw@mail.gmail.com> <YkpZH28mfZHlsd2T@CptOrmolo.darkstar> <YkpqyANtIznaB1tC@CptOrmolo.darkstar>
> 2022/04/04 12:49, Matthew Martin <phy1729@xxxxxxxxx> wrote:
>
> OpenBSD has gutted the pty route and strongly prefers openpty over
> posix_openpt. Is there a correct way link the zpty module against
> libutil?
Please try the following patch.
Replace the pattern (in configure.ac)
openbsd*)
by
openbsd7*)
or such if openpty() should be used only on specific versions of OpenBSD.
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c
index dfd2a2a7a..cdab1d8e1 100644
--- a/Src/Modules/zpty.c
+++ b/Src/Modules/zpty.c
@@ -249,6 +249,28 @@ get_pty(int master, int *retfd)
return 0;
}
+/* openpty() is prefered on OpenBSD */
+#elif defined(__OpenBSD__) && defined(HAVE_OPENPTY)
+
+#include <util.h>
+
+static int
+get_pty(int master, int *retfd)
+{
+ static int mfd, sfd;
+
+ if (master) {
+ if (openpty(&mfd, &sfd, NULL, NULL, NULL) == -1)
+ return 1;
+
+ *retfd = mfd;
+ return 0;
+ }
+
+ *retfd = sfd;
+ return 0;
+}
+
#else /* No /dev/ptmx or no pt functions */
static int
diff --git a/configure.ac b/configure.ac
index 8bba78c56..6aae71300 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2441,6 +2441,18 @@ int ptsname();]], [[]])],[ac_cv_use_dev_ptmx=no],[ac_cv_use_dev_ptmx=yes])])
fi
fi
+dnl On (some) OpenBSD, it seems openpty() is the only reliable way to get pty.
+AH_TEMPLATE([HAVE_OPENPTY],
+[Define to 1 if openpt() is available on OpenBSD])
+case "$host_os" in
+ openbsd*)
+ AC_SEARCH_LIBS(openpty, util)
+ if test x$ac_cv_search_openpty != xno; then
+ AC_DEFINE(HAVE_OPENPTY)
+ fi
+ ;;
+esac
+
dnl -----------------
dnl multibyte support
dnl -----------------
Messages sorted by:
Reverse Date,
Date,
Thread,
Author