[fblocked] on cmd pipe always returns 0
Closed / Fixed519868ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 42 days ago
Descriptionplain2002-02-19 11:10:51
starting with Tcl8.1 the fblocked command applied to
a command pipe always returns false, even if the
recent [read] returned less bytes than wanted.
Example script:
puts Tcl:$tcl_patchLevel
set in [open "|/bin/sh -c {sleep 2; echo Hallo
Welt}"]
fconfigure $in -blocking 0 -translation binary
while {42} {
set bytes [read $in 11]
if {[eof $in]} {
close $in
break
}
puts [format "read of %d bytes was %sblocked" \
[string length $bytes] \
[expr {[fblocked $in] ? "" : "non "}]]
after 1100
}
Output for various Tcl versions:
> tcl8.0.5/unix/tclsh fblocked.tcl
Tcl:8.0.5
read of 0 bytes was blocked
read of 0 bytes was blocked
read of 11 bytes was non blocked
> tcl8.1.1/unix/tclsh fblocked.tcl
Tcl:8.1.1
read of 0 bytes was non blocked
read of 0 bytes was non blocked
read of 11 bytes was non blocked
> tcl8.4a3/unix/tclsh fblocked.tcl
Tcl:8.4a3
read of 0 bytes was non blocked
read of 0 bytes was non blocked
read of 11 bytes was non blocked
matzekplain2004-05-03 19:02:28
Logged In: YES user_id=330806 > /usr/local/ActiveTcl/bin/tclsh8.4 ~/fblocked.tcl Tcl:8.4.6 read of 0 bytes was non blocked read of 0 bytes was non blocked read of 11 bytes was non blocked Will this ever get fixed?
serhiy.storchakawiki2026-10-21 10:03:37
Fixed in 8.5.16 and 8.6.2 by the CHANNEL_BLOCKED/EOF rework [2a40293a49] (8.5: [f6b7d496c4]): after a short non-blocking read from a command pipe, fblocked now returns 1.
serhiy.storchaka Ticket [519868ffff]: 3 changes
[History diff]2026-10-22 17:19:30
Log in (anonymous is fine) to add a comment.