[Gambas-user] Watching File and Pipe

Benoît Minisini gambas at ...1...
Sun Jan 6 02:45:42 CET 2013


Le 06/01/2013 02:20, Tobias Boege a écrit :
> Hi Benoit,
>
> here's the story: I originally wanted to redirect the Error
> instruction's default stream to a pipe which I could then read from
> in the same application. For some reason I got a "Bad file
> descriptor" (must be EBADF?) error when using
>
> Error "test"
>
> after having redirected
>
> Error To #File.In

File.In is associated with a file descriptor opened for reading, so this
is a non-sense.

The only thing you can do is Error To #File.Out.

>
> I am used to stdin being open and writable but maybe things are
> different in graphical applications - would be logical; I don't
> know...

Where did you read that? Did you notice the "in" in "stdin"?

>
> However, it didn't work so I tried with a temporary file - I simply
> needed a stream with one read and one write end.
>
> The problem now is, when I try to watch a File or Pipe created using
> either
>
> hFile = Open sPath For Input Output Create Watch
>
> or
>
> hPipe = Pipe sPath For Read Write Watch
>
> that the File_Read() event is called without end

Logical, as a normal file is always ready to be read.

> and Pipe_Read() is never called.
>
> Moreover, the Pipe seems to raise the File_Read() event and not the
> Pipe_Read() one and the file does not raise either event. The
> combination of the creation flags does _not_ seem to be the reason. I
> got the same results when using distinct read and write streams for
> both of them.

All streams use "File_" as event handler prefix, even pipes.

And the Read event will be raised when there is something to read on the 
pipe.

Regards,

-- 
Benoît Minisini




More information about the User mailing list