summaryrefslogblamecommitdiff
path: root/system/expect/linux-5.10-tty.patch
blob: 807f519b20e5348c67fd7079be2dbf390efca993 (plain) (tree)
























                                                                     
From: Adam Sampson <ats@offog.org>
Subject: Re: dejagnu-1.6.3 test failure
Message-ID: <YXNTBvEAQP0jAgiq@cartman.at.offog.org>

After a bit of debugging, the cause seems to be that expect uses
Tcl_GetsObj to read from stdin, and treats a -1 return value as an
error. However, Tcl_GetsObj can also return -1 to indicate that input
was blocked, i.e. it didn't manage to read a complete line -- expect
didn't handle this case.

This patch seems to fix the problem:

--- expect5.45.4/exp_main_sub.c 2018-02-04 10:43:58.000000000 +0000
+++ expect5.45.4/exp_main_sub.c 2021-10-23 00:39:09.375404444 +0100
@@ -326,7 +326,9 @@

 	if (code != EXP_EOF) {
 	    inChannel = expStdinoutGet()->channel;
-	    code = Tcl_GetsObj(inChannel, commandPtr);
+	    do {
+		code = Tcl_GetsObj(inChannel, commandPtr);
+	    } while (code < 0 && Tcl_InputBlocked(inChannel));
 #ifdef SIMPLE_EVENT
 	    if (code == -1 && errno == EINTR) {
 		if (Tcl_AsyncReady()) {