Not very elegant, as it relies on thrown errors:
proc isReadable {chan} {
if {[catch {fileevent $chan readable}]} {
return 0; # fileevent complained, so it's not
} else {
return 1; # fileevent queried the handler: harmless
}
}
isReadable stdin
isReadable stdout
For isWritable copy the body for isReadable and replace
readable by writable (note: *not* writ_e_able)