Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-22
17:19 • Ticket [519868ffff] fblocked on cmd pipe always returns 0 status still Clo... artifact: 133321b3e8 user: serhiy.storchaka
2026-10-21
10:03 • Closed ticket [519868ffff]. artifact: 556689879c user: serhiy.storchaka
2004-05-03
19:02 • Ticket [519868ffff]: 4 changes artifact: 619b142f34 user: matzek
2002-02-19
11:10 • New ticket [519868ffff]. artifact: 29da20aee4 user: krischan

[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.