summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclIO.c9
-rw-r--r--tests/io.test20
2 files changed, 24 insertions, 5 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index c8c9aec..5cdf2c3 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -4799,11 +4799,6 @@ TclGetsObjBinary(
* hasn't seen EOL. Need to read more bytes from the channel
* device. Side effect is to allocate another channel buffer.
*/
-
- if (GotFlag(statePtr, CHANNEL_BLOCKED|CHANNEL_NONBLOCKING)
- == (CHANNEL_BLOCKED|CHANNEL_NONBLOCKING)) {
- goto restore;
- }
if (GetInput(chanPtr) != 0) {
goto restore;
}
@@ -4870,6 +4865,10 @@ TclGetsObjBinary(
}
goto gotEOL;
}
+ if (GotFlag(statePtr, CHANNEL_BLOCKED|CHANNEL_NONBLOCKING)
+ == (CHANNEL_BLOCKED|CHANNEL_NONBLOCKING)) {
+ goto restore;
+ }
/*
* Copy bytes from the channel buffer to the ByteArray.
diff --git a/tests/io.test b/tests/io.test
index cf38a1b..c3aaa86 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -4945,6 +4945,26 @@ test io-36.1 {Tcl_InputBlocked on nonblocking pipe} {stdio openpipe} {
close $f1
set x
} {{} 1 hello 0 {} 1}
+test io-36.1.1 {Tcl_InputBlocked on nonblocking binary pipe} {stdio openpipe} {
+ set f1 [open "|[list [interpreter]]" r+]
+ chan configure $f1 -encoding binary -translation lf -eofchar {}
+ puts $f1 {puts hello_from_pipe}
+ flush $f1
+ gets $f1
+ fconfigure $f1 -blocking off -buffering full
+ puts $f1 {puts hello}
+ set x ""
+ lappend x [gets $f1]
+ lappend x [fblocked $f1]
+ flush $f1
+ after 200
+ lappend x [gets $f1]
+ lappend x [fblocked $f1]
+ lappend x [gets $f1]
+ lappend x [fblocked $f1]
+ close $f1
+ set x
+} {{} 1 hello 0 {} 1}
test io-36.2 {Tcl_InputBlocked on blocking pipe} {stdio openpipe} {
set f1 [open "|[list [interpreter]]" r+]
fconfigure $f1 -buffering line