Advanced Search
Mail us
Home    Manuel    Links    Faq    Submit a tcl/tk Reference    Contact Us

    Some examples tcl/tk codes     Man of Bwidget     Man of blt     mkwidget screenshots     TkOgl     Video Demo real.

  read and write from a pipe without locking up?
 The stdio package has an optimization for speed that buffers characters so 
that you can avoid un-necessary system calls. This isn`t very good for 
interactive use so stdio changes it`s behaviour if the file is a terminal. When 
you write to a pipe you are not writing to a terminal and so your output is 
buffered, similarly when the program at the other end of the pipe writes its 
response it is also buffered. The end result is the programs at both end of the 
pipe stall waiting for input. It is possible to force the buffers to be written 
using flush in Tcl and fflush() in C, often though, you don`t have control over 
the program at the other end of the pipeline and in that case your only 
solution is to use a pseudo-teletype (pty). Unfortunately this isn`t all that 

While this isn`t directly supported in Tcl the spawn command in expect opens a 
pty and starts a command.