Expect version: 5.45 (src.rpm from fc22 backported to rhel65)
Tcl version: 8.6.3 (src.rpm from fc22 backported to rhel65)
Unable to reproduce the behavior in a simplified setup, but here is what happens: When the syscall read() returns EAGAIN, then expIRead returns 0 which is documented to be EOF.
Problem Behaviour:
Expected Behavior:
The calling [expect] times out gracefully, i.e. the timeout pattern matches.
The I/O subsystem released in Tcl 8.6.3 is broken. You should not use that release. Upgrade to Tcl 8.6.4 and see if the problem continues.
The problem continues after the upgrade. Here are more facts:
++ ExpInputProc
++ ChanRead
++ GetInput
++ DoReadChars
++ expIRead
++ expRead
++ Exp_ExpectObjCmd
++ -timeout 0
++ expect on a socket
++ expect with no (further) data available
I wondered whether Tcl or Expect is designed to only ever call read() when data is available and EWOULDBLOCK should not happen at all.
Last edit: heinrichmartin 2015-11-10
Please provide a script that demonstrates the problem.
Ideally you will confirm that the script works properly with
Tcl 8.6.1 but fails in the current release of Tcl 8.6.4.
Thank you.
Summary from private mail:
When syscall read() returns -1 with EAGAIN or EWOULDBLOCK, then the call stack looks like this:
The attached patch resolves the problem for me. I chose to patch expIRead in order to keep the code comment's promise (to return 0 in case of EOF).
This is an alternative patch that is more simple, but it does not fix the misinterpretation in expIRead. Other bugs might be dormant and the patch is untested.
Last edit: heinrichmartin 2015-11-13
This is actually fixed in 5.45.3, but which is not the latest downloadable file.
https://sourceforge.net/p/expect/bugs/99/
https://sourceforge.net/p/expect/patches/18/ (superseds https://sourceforge.net/p/expect/patches/14/)
Fixed in 5.45.3 .