Tcl question: fileevent: Does it block?

Joel Hammer joel
Mon May 17 11:57:40 PDT 2004


Can you point me to some simple script samples on the internet which
use fileevent?  I really need to find out why fileevent in my hands blocks.

Thanks

Joel

On Wed, Dec 31, 2003 at 01:18:06PM +0100, Roger Oberholtzer wrote:
> fileevent, by nature, should be non-blocking. That is, it is usually set
> up so that the code is only called when there is the requested activity
> on the channel However, once in the fileevent handler, you can do
> whatever you want, including trying to read more than is there or
> writing when the output channel is full. How the channel acts depends on
> you set it up with 'fconfigure'. 
> 
> On Wed, 2003-12-31 at 02:07, Joel Hammer wrote:
> > Rank beginner here.
> > 
> > >From reading the documentation of fileevent, I got the impression it
> > simply registers a procedure with a file event and then the script moves
> > on. That isn't my experience.
> > 
> > This little snippet hangs at the fileevent line if there is no input in
> > the pipe.  Once there is something to read in the pipe, the SomeProcedure
> > is called and processing of the script moves to the puts line after
> > the fileevent line. Additional input to the pipe is ignored. This is
> > like nothing I expected from reading the documentation. It makes the
> > fileevent command no better than a while loop.
> > 
> > BTW, I load the pipe with echo commands from another terminal.
> > 
> > Any insight appreciated.
> > 
> > Joel
> > 
> > #!/etc/alternatives/wish -f
> > set i 0
> > set  id [ open /tmp/NewPipe r ]
> > fileevent $id readable [list SomeProcedure $id]
> > puts "beyond  filevent" 


More information about the Linux-users mailing list