Tcl question: fileevent: Does it block?

Roger Oberholtzer roger
Mon May 17 11:57:42 PDT 2004


On Wed, 2003-12-31 at 23:10, Joel Hammer wrote:
> Here is a code snippet that works all as expected: The script runs
> through all its commands, and waits for input in the pipe. No blocking.
> 
> When input arrives, the GetData proc is activated and reads what is
> in the pipe, whether there is one or many lines in the pipe  Great.
> However, this only happens once.  Additional input into the pipe is
> ignored, the pipe seeming to be closed.
> 
> Changing fconfig to -blocking true didn't make any difference.
> 
> Any hints appreciated,
> 
> Joel
> 
> 
> #!/etc/alternatives/wish -f
> proc GetData {chan} {
>     while {![eof $chan]} {
>         gets $chan f
> }
> set  id [ open /tmp/NewPipe {RDONLY NONBLOCK} ]
> fconfigure $id -blocking false
> fileevent $id readable [list GetData $id ]

the list command wants the output of the GetData command. As you wrote
it, the text 'GetData' is in the list, not the result of the command. So
I added the additional [].

	fileevent $id readable [list [GetData $id]]

Not sure if this is the problem. What is at the other end of the pipe?




More information about the Linux-users mailing list