【发布时间】:2017-11-08 07:17:15
【问题描述】:
我正在尝试使用 fileevent 跟踪文件(应该只有 Tcl 8.4 版本,所以我不能使用 chan 命令)。
% proc GetData {chan} {
set data [read $chan]
puts "[string length $data] $data"
if {[eof $chan]} {
fileevent $chan readable {}
}
}
%
%
%
% set fp [open "|tail -f /home/dinesh/input" r+]
file7
% fconfigure $fp
-blocking 1 -buffering full -buffersize 4096 -encoding utf-8 -eofchar {{} {}} -translation {auto lf}
% fconfigure $fp -blocking 0 -buffering line
%
%
%
%
% fileevent $fp readable [list GetData $fp]
%
我已经在另一个终端中使用cat 命令更改了文件内容,但仍然没有调用GetData。
使用gets $fp line,我可以得到修改后的内容,但是为什么没有触发fileevent?
【问题讨论】: