#!../wafe --f
# a program to test various approaches to use addInput/removeInput
# Gustaf Neumann                      Thu Oct 21 02:14:43 GMT 1993
set testfile ttt

if ![file readable $testfile] {
    puts stderr "*** This program produces output when data is appended to '$testfile'"
    puts stderr "*** File '$testfile' is not readable, aborting."
    quit
}


proc mightBeBusy {file} {
  addInput [fileno $file r] read buffer { puts stderr "file=<$buffer>" }
}

proc checkRememberData {file} {
  set inputId [addInput [fileno $file r] read buffer {
    puts stderr "file=<$buffer>"
  }]
  addTimeOut 0 "removeInput $inputId"
  addTimeOut 100 "checkRememberData $file"
}


proc checkData {file} {
  set inputId [addInput [fileno $file r] read buffer {
    puts stderr "buffer=<$buffer>"
    set buffer {}
  }]
  addTimeOut 0 "removeInput $inputId"
  addTimeOut 100 "checkData $file"
}

set f [open ttt r]
#mightBeBusy $f
#checkRememberData $f
checkData $f

