Sun Jun 19 22:22:22 2022 UTC ()
lang/tcl-expect: Limit deadlock workaround to affected platforms

This caused a build failure on OpenServer.  As the comment hinted
would be necessary, limit the workaround to linux and sunos, which are
known to have poll.  (expect does not have a configure test for poll
already.)


(gdt)
diff -r1.35 -r1.36 pkgsrc/lang/tcl-expect/Makefile
diff -r1.25 -r1.26 pkgsrc/lang/tcl-expect/distinfo
diff -r1.2 -r1.3 pkgsrc/lang/tcl-expect/patches/patch-exp__chan.c

cvs diff -r1.35 -r1.36 pkgsrc/lang/tcl-expect/Makefile (expand / switch to unified diff)

--- pkgsrc/lang/tcl-expect/Makefile 2022/05/15 01:56:24 1.35
+++ pkgsrc/lang/tcl-expect/Makefile 2022/06/19 22:22:21 1.36
@@ -1,19 +1,19 @@ @@ -1,19 +1,19 @@
1# $NetBSD: Makefile,v 1.35 2022/05/15 01:56:24 dholland Exp $ 1# $NetBSD: Makefile,v 1.36 2022/06/19 22:22:21 gdt Exp $
2 2
3.include "Makefile.common" 3.include "Makefile.common"
4 4
5PKGNAME= tcl-expect-${EXPECT_VERSION} 5PKGNAME= tcl-expect-${EXPECT_VERSION}
6PKGREVISION= 5 6PKGREVISION= 6
7CATEGORIES= lang 7CATEGORIES= lang
8 8
9MAINTAINER= pkgsrc-users@NetBSD.org 9MAINTAINER= pkgsrc-users@NetBSD.org
10COMMENT= Extensions to Tcl to support scripting of interactive programs 10COMMENT= Extensions to Tcl to support scripting of interactive programs
11LICENSE= public-domain 11LICENSE= public-domain
12 12
13USE_GCC_RUNTIME= yes 13USE_GCC_RUNTIME= yes
14 14
15CONFIGURE_ARGS+= --enable-shared 15CONFIGURE_ARGS+= --enable-shared
16CONFIGURE_ARGS+= --with-tclconfig=${BUILDLINK_PREFIX.tcl}/lib 16CONFIGURE_ARGS+= --with-tclconfig=${BUILDLINK_PREFIX.tcl}/lib
17CONFIGURE_ARGS+= --without-x 17CONFIGURE_ARGS+= --without-x
18 18
19INSTALL_MAKE_FLAGS+= INSTALL_ROOT=${DESTDIR:Q} 19INSTALL_MAKE_FLAGS+= INSTALL_ROOT=${DESTDIR:Q}

cvs diff -r1.25 -r1.26 pkgsrc/lang/tcl-expect/distinfo (expand / switch to unified diff)

--- pkgsrc/lang/tcl-expect/distinfo 2022/06/19 14:43:28 1.25
+++ pkgsrc/lang/tcl-expect/distinfo 2022/06/19 22:22:21 1.26
@@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
1$NetBSD: distinfo,v 1.25 2022/06/19 14:43:28 gdt Exp $ 1$NetBSD: distinfo,v 1.26 2022/06/19 22:22:21 gdt Exp $
2 2
3BLAKE2s (expect5.45.tar.gz) = 38c440ed0868322b6ec7438decaa036a636e7d700191b754c1e4a7dc0fdd0c46 3BLAKE2s (expect5.45.tar.gz) = 38c440ed0868322b6ec7438decaa036a636e7d700191b754c1e4a7dc0fdd0c46
4SHA512 (expect5.45.tar.gz) = be991c68241e607b3a689eae7e7966056dbfb577e857331d54a4911bd178c1816425217603b43918ad1b6d2e966271a0f01e79d7028a22e223562d59d10c8c51 4SHA512 (expect5.45.tar.gz) = be991c68241e607b3a689eae7e7966056dbfb577e857331d54a4911bd178c1816425217603b43918ad1b6d2e966271a0f01e79d7028a22e223562d59d10c8c51
5Size (expect5.45.tar.gz) = 628808 bytes 5Size (expect5.45.tar.gz) = 628808 bytes
6SHA1 (patch-Makefile.in) = 06858e50b7517901d0a7dc58f2149e7ef09b615b 6SHA1 (patch-Makefile.in) = 06858e50b7517901d0a7dc58f2149e7ef09b615b
7SHA1 (patch-configure) = 51ae6c4aaf6ff1ac510aec0d062310a91cb959c2 7SHA1 (patch-configure) = 51ae6c4aaf6ff1ac510aec0d062310a91cb959c2
8SHA1 (patch-exp__chan.c) = 045d3442cfdc0976c8767a6cbdd9bbf2dcc8ed87 8SHA1 (patch-exp__chan.c) = 20fa6d6902f0a60c6f9767de60178ad8860a2229

cvs diff -r1.2 -r1.3 pkgsrc/lang/tcl-expect/patches/patch-exp__chan.c (expand / switch to unified diff)

--- pkgsrc/lang/tcl-expect/patches/patch-exp__chan.c 2022/06/19 14:43:28 1.2
+++ pkgsrc/lang/tcl-expect/patches/patch-exp__chan.c 2022/06/19 22:22:22 1.3
@@ -1,51 +1,57 @@ @@ -1,51 +1,57 @@
1$NetBSD: patch-exp__chan.c,v 1.2 2022/06/19 14:43:28 gdt Exp $ 1$NetBSD: patch-exp__chan.c,v 1.3 2022/06/19 22:22:22 gdt Exp $
2 2
3Add hack to work around deadlock situation that occurs on Solaris and 3Add hack to work around deadlock situation that occurs on Solaris and
4Linux. See PR 34442. 4Linux. See PR 34442.
5 5
6The problem apparently does not occur on BSD, but it doesn't seem to 6The problem apparently does not occur on BSD, but it doesn't seem to
7be clear why or whether that's really the case; the description of the 7be clear why or whether that's really the case; the description of the
8problem as far as it's understood seems to be portable. So don't 8problem as far as it's understood seems to be portable. So don't
9conditionalize it, as the check should be safe. If this turns out to 9conditionalize it, as the check should be safe. If this turns out to
10cause problems, we can wrap it in ifdefs. 10cause problems, we can wrap it in ifdefs.
11 11
12\todo File changes upstream (but upstream is not functioning). 12\todo File changes upstream (but upstream is not functioning).
13 13
14--- exp_chan.c.orig 2010-07-01 00:53:49.000000000 +0000 14--- exp_chan.c.orig 2010-07-01 00:53:49.000000000 +0000
15+++ exp_chan.c 15+++ exp_chan.c
16@@ -7,6 +7,7 @@ 16@@ -7,6 +7,9 @@
17 */ 17 */
18  18
19 #include <sys/types.h> 19 #include <sys/types.h>
 20+#if defined(linux) || defined(sunos)
20+#include <sys/poll.h> 21+#include <sys/poll.h>
 22+#endif
21 #include <stdio.h> 23 #include <stdio.h>
22 #include <signal.h> 24 #include <signal.h>
23 #include <errno.h> 25 #include <errno.h>
24@@ -205,6 +206,8 @@ ExpInputProc(instanceData, buf, toRead,  26@@ -205,6 +208,10 @@ ExpInputProc(instanceData, buf, toRead,
25 ExpState *esPtr = (ExpState *) instanceData; 27 ExpState *esPtr = (ExpState *) instanceData;
26 int bytesRead; /* How many bytes were actually 28 int bytesRead; /* How many bytes were actually
27 * read from the input device? */ 29 * read from the input device? */
 30+#if defined(linux) || defined(sunos)
28+ struct pollfd fds[1]; 31+ struct pollfd fds[1];
29+ int pollResult; 32+ int pollResult;
 33+#endif
30  34
31 *errorCodePtr = 0; 35 *errorCodePtr = 0;
32  36
33@@ -215,6 +218,18 @@ ExpInputProc(instanceData, buf, toRead,  37@@ -215,6 +222,20 @@ ExpInputProc(instanceData, buf, toRead,
34 * nonblocking, the read will never block. 38 * nonblocking, the read will never block.
35 */ 39 */
36  40
 41+#if defined(linux) || defined(sunos)
37+ /* Update: there isn't always, which can lead to hangs. See PR 34442. */ 42+ /* Update: there isn't always, which can lead to hangs. See PR 34442. */
38+ fds[0].fd = esPtr->fdin; 43+ fds[0].fd = esPtr->fdin;
39+ fds[0].events = POLLIN | POLLERR | POLLHUP | POLLNVAL; 44+ fds[0].events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
40+ pollResult = poll(fds, 1, 0); 45+ pollResult = poll(fds, 1, 0);
41+ if (pollResult <= 0) { 46+ if (pollResult <= 0) {
42+ *errorCodePtr = EWOULDBLOCK; 47+ *errorCodePtr = EWOULDBLOCK;
43+ return -1; 48+ return -1;
44+ } else if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { 49+ } else if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) {
45+ *errorCodePtr = EBADF; 50+ *errorCodePtr = EBADF;
46+ return -1; 51+ return -1;
47+ } 52+ }
 53+#endif
48+ 54+
49 bytesRead = read(esPtr->fdin, buf, (size_t) toRead); 55 bytesRead = read(esPtr->fdin, buf, (size_t) toRead);
50 /*printf("ExpInputProc: read(%d,,) = %d\r\n",esPtr->fdin,bytesRead);*/ 56 /*printf("ExpInputProc: read(%d,,) = %d\r\n",esPtr->fdin,bytesRead);*/
51 if (bytesRead > -1) { 57 if (bytesRead > -1) {