zsh-workers
 help / color / mirror / code / Atom feed
From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: Hang in E01 due to zpty on OpenBSD
Date: Mon, 4 Apr 2022 17:34:09 +0900	[thread overview]
Message-ID: <4BCAE950-2D78-415A-88C3-8362946DC74C@kba.biglobe.ne.jp> (raw)
In-Reply-To: <YkpqyANtIznaB1tC@CptOrmolo.darkstar>


> 2022/04/04 12:49, Matthew Martin <phy1729@gmail.com> 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 -----------------





  reply	other threads:[~2022-04-04  8:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-03 21:42 Matthew Martin
2022-04-04  1:04 ` Bart Schaefer
2022-04-04  2:34   ` Matthew Martin
2022-04-04  3:49     ` Matthew Martin
2022-04-04  8:34       ` Jun T [this message]
2022-04-04 11:21         ` Mikael Magnusson
2022-04-04 13:16         ` Matthew Martin
2022-04-06  5:48           ` Jun T
2022-04-06 12:53             ` Matthew Martin
2022-04-06 20:12               ` Bart Schaefer
2022-04-07  3:47               ` Jun T
2022-04-07  4:52                 ` Matthew Martin
2022-04-08  7:51                   ` Jun T
2022-04-04  2:39 ` Jun T
2022-04-04  2:51   ` Matthew Martin

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=4BCAE950-2D78-415A-88C3-8362946DC74C@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --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).