From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21139 invoked from network); 6 Apr 2022 12:54:16 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 6 Apr 2022 12:54:16 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1649249656; b=kyIarvIbQVLkjp+1EaK2VI4Vjc2QtnMu0ToLC7NfCxANa6hBZkTZkKd2MErhKtQIAOsYany2wN xJ1gwQHCJGZkQZYS/10a7byy1C2bm+NJSCCO4kEN8bGXrGjJdf+vud7tguSp90Auhjlg2Z6/IQ NXSnwSDpE0n78A0zc7mG3h1Y6OIngOMdZFsxMe+7ko/BPI/C5Zz3QIOi962x1RePRzXImStWjW Yu/CQGIU+rj7wpO/0J6aiyc3g9QXC2QdEfVJuM97uJDR/Ut3So7mVt9smPyalpDsD7lbkTsEOP JlemkJ0wK6q9KVrx8EwX4d5v9OfpaidLDxBLGJsXGINj6w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oa1-f53.google.com) smtp.remote-ip=209.85.160.53; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1649249656; bh=DPs+74ITS9ShPX2Lw/CbRAesUyim1Zu+BvGg/JQZXWw=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:From:Date:DKIM-Signature:DKIM-Signature; b=CR92ZBp/Tuc9SxxZm2nmdviOVlUNSfYGgLWbDe9uVeRwXbbvxGzVSKUZ6vFMCetFT5gIYxUZOW QRzAT0Kj0RmCIng9rWpxOtT/OL89U2HH6Esa53l+rOgu85EXjcELktTlxfusmMDlnk+AnlS0mH xr6RwOlYhcoHV5Lmz7ih5K0dK96Z39C8zd+1IHWTbXaS6f88oH3e1z1RQpIwyAatKC9FMjjn8z QCJVq/U85uob0PLwizjt1HJeXX7ERF3LnHnBCHP4e0U6ZBOL9l+PMLlr33SSoxNptwtXwde3lU CacNTBtYYjEcsaAWuwtAKGRaFRxlH5VaCL5iguwfO3vkNA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:To:From:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=30LT4dCplRsfNgdhhSaOGq5MxGphjH7OHr2jnhKSckc=; b=SoNM039XGsBVq2tkZULfYs8qrX ka5l9UEaFx9bFi6XO6+Rm/kYVlcFZ2JEz69lIoCLsOVlZa+DoiATqeY29SXUKMVUS4KwFAsq7GxZG +IvIdOYGRzFEqhzYjoHsy2FpNTehD/Ud1pMMo5olQAV+usAs4767lyUTON6F/M8ZMiR3a4IBuwupc QysFu7wlAgtig9ZNlnzuBucoRjg6/ut9b3tk1b1CSvPnpPzpJben61gK9gxnh1JKqtfnj4blvpbpy jUULo4JSoueaIKI4EO5WQioWWrax55N6Hkhdq844Jz9OGIzgf/V7LRVMO3sN4x04FAFo2CEjFa5Wm BkhwNAQg==; Received: from authenticated user by zero.zsh.org with local id 1nc5At-0001zi-MK; Wed, 06 Apr 2022 12:54:15 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oa1-f53.google.com) smtp.remote-ip=209.85.160.53; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-oa1-f53.google.com ([209.85.160.53]:36506) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nc5AO-0001fL-Fw; Wed, 06 Apr 2022 12:53:45 +0000 Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-df22f50e0cso2779607fac.3 for ; Wed, 06 Apr 2022 05:53:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=30LT4dCplRsfNgdhhSaOGq5MxGphjH7OHr2jnhKSckc=; b=dx7B3oErSFmmnWzI1YfcI6k+S6AgBgKDaJKHAVVKfcF0923mnLYJNQsHH99A8llNZM kYZT3w6sqJaoHx7T4vMM1gCLHd0P2GCJ6A+wfk/djXKJ9P4a7WQJOx8NlNxeT6OHOB7c RVx4HfUHdC/VqjwWfSvPJtSaRxExFeC76cJ12FFmZMkDZr+1RjLBNlgzrgpba6Sggtad FNaKQPao24qFVFI/u/Subq6WDa0pDxNZZohr7brWt93NiJt/iap9z2wuWZiBG389UHCS 87gOt0HPghVBdFonH5AQZgA4siXKdUnwrhyLZrjNiqPN1u+3EpdggaI3RtJuiQ5H+s9l 00Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to; bh=30LT4dCplRsfNgdhhSaOGq5MxGphjH7OHr2jnhKSckc=; b=rv5VNXOib29OcfwBgFCJnim3nBEQy+Petcwx6cyoQro1uHHEoRCPmkZa5zLM09KAto PFEafyjnuPj7XITxBJKaBjeIcQExb8dqkzLKR2zdiDAvYVHM7arHC9+9+P0lyhWOts1f ikOw5oWYnzgZb8m3ISEkq1oxYe1ZRO/uNfabcN1XsiDrhtm7lXrR+7Rnw9RIp1pjfMZG WoWukqHJZrZCKBXicNMhUP1Q2ihfsUnejRQ7sKp28QlL1edlPOv4i3abDa8krUNf7PV3 1PHE/yaMz7Hk/bloQrhG1eXq8EckQiTxWl2A6O0d249x8F1tJs64BAuFyeLIbYMVzWcc amBg== X-Gm-Message-State: AOAM532o8fwfFe132YesTAAm/KtUxIouPdsLJ/bNQaMX/C/t6QWDWvba DiGKndcBntQk+Q1lxpW+Ld72PR6lVMU= X-Google-Smtp-Source: ABdhPJy6YTL+3lOo6Pp6Z/4clramt0lCtGJKdkHKoDK1Z7yki1SOeKz9Yi1yy4zmlm3hjKR62Q7ZPQ== X-Received: by 2002:a05:6870:171e:b0:e1:f06d:e81 with SMTP id h30-20020a056870171e00b000e1f06d0e81mr3661624oae.79.1649249622626; Wed, 06 Apr 2022 05:53:42 -0700 (PDT) Received: from CptOrmolo.darkstar (cpe-76-184-110-212.tx.res.rr.com. [76.184.110.212]) by smtp.gmail.com with ESMTPSA id l1-20020a056830268100b005c93e625b9dsm7565443otu.46.2022.04.06.05.53.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:53:42 -0700 (PDT) Date: Wed, 6 Apr 2022 07:53:39 -0500 From: Matthew Martin To: zsh-workers@zsh.org Subject: Re: Hang in E01 due to zpty on OpenBSD Message-ID: Mail-Followup-To: zsh-workers@zsh.org References: <4BCAE950-2D78-415A-88C3-8362946DC74C@kba.biglobe.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 50001 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Wed, Apr 06, 2022 at 02:48:00PM +0900, Jun T wrote: > > > 2022/04/04 22:16, Matthew Martin wrote: > > > > On Mon, Apr 04, 2022 at 05:34:09PM +0900, Jun T wrote: > > > >> Replace the pattern (in configure.ac) > >> openbsd*) > >> by > >> openbsd7*) > >> or such if openpty() should be used only on specific versions of OpenBSD. > > > > I would only support OpenBSD-current unless anyone objects > > We can't specify -current here. > I've upgraded to OpenBSD-7.1 but still can't reproduce your problem. > > But since openpty() works fine on OpenBSD7.0/7.1, I will push the patch > with 'openbsd7*)' (with Mikael's fix of typo) if there is no objection. I'd prefer something like the below where it's a feature test instead of an OS test. diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index dfd2a2a7a..f4c95537d 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -37,6 +37,15 @@ #endif #endif +#ifdef HAVE_OPENPTY +#ifdef OPENPTY_REQUIRES_PTY +#include +#elif defined(OPENPTY_REQUIRES_UTIL) +#include +#include +#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). */ @@ -161,8 +170,26 @@ getptycmd(char *name) return NULL; } -/* posix_openpt() seems to have some problem on OpenBSD */ -#if defined(USE_DEV_PTMX) && !defined(__OpenBSD__) +#ifdef HAVE_OPENPTY + +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; +} + +#elifdef USE_DEV_PTMX #ifdef HAVE_SYS_STROPTS_H #include @@ -261,12 +288,7 @@ get_pty(int master, int *retfd) #elif defined(__FreeBSD__) || defined(__DragonFly__) static char char1[] = "pqrsPQRS"; static char char2[] = "0123456789abcdefghijklmnopqrstuv"; -#elif defined(__OpenBSD__) - static char char1[] = "pqrstuvwxyzPQRST"; - static char char2[] = "0123456789" - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -#else /* __FreeBSD__ || __DragonFly__ || __OpenBSD*/ +#else /* __FreeBSD__ || __DragonFly__ */ static char char1[] = "pqrstuvwxyzPQRST"; static char char2[] = "0123456789abcdef"; #endif diff --git a/configure.ac b/configure.ac index 8bba78c56..e3ff0aca4 100644 --- a/configure.ac +++ b/configure.ac @@ -2400,6 +2400,37 @@ dnl --------------- zsh_CHECK_SOCKLEN_T +dnl --------------- +dnl Check for openpty support +dnl --------------- +AH_TEMPLATE([HAVE_OPENPTY], + [Define to 1 if you have the `openpty' function.]) +AH_TEMPLATE([OPENPTY_REQUIRES_PTY], + [Define to 1 if the `openpty' function requires pty.h.]) +AH_TEMPLATE([OPENPTY_REQUIRES_UTIL], + [Define to 1 if the `openpty' function requires termios.h and util.h.]) +AC_MSG_CHECKING([for openpty]) +openpty=no +AC_LINK_IFELSE([AC_LANG_SOURCE( +[[#include +int main () { int (*p)(int *, int *, char *, const struct termios *, const struct winsize *) = openpty; }]])], + [AC_DEFINE([HAVE_OPENPTY]) + AC_DEFINE([OPENPTY_REQUIRES_PTY]) + openpty=yes]) +if test $openpty = no; then +AC_LINK_IFELSE([AC_LANG_SOURCE( +[[#include +#include +int main () { int (*p)(int *, int *, char *, const struct termios *, const struct winsize *) = openpty; }]])], + [AC_DEFINE([HAVE_OPENPTY]) + AC_DEFINE([OPENPTY_REQUIRES_UTIL]) + openpty=yes]) +fi +AC_MSG_RESULT([$openpty]) +if test $openpty = yes; then +AC_SEARCH_LIBS(openpty, util) +fi + dnl --------------- dnl Check for pty multiplexer for use in pty module. dnl We need to open it read/write, so make sure it is writeable.