Tcl question: fileevent: Does it block?
Roger Oberholtzer
roger
Mon May 17 11:57:39 PDT 2004
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"
>
> _______________________________________________
> Linux-users mailing list
> Linux-users at smtp.linux-sxs.org
> Unsubscribe/Suspend/Etc -> http://smtp.linux-sxs.org/mailman/listinfo/linux-users
More information about the Linux-users
mailing list