[fpc-pascal] TFileStream and stdin - how to make this work?

Bernd Kreuss prof7bit at googlemail.com
Sun Oct 3 16:09:55 CEST 2010


On 03.10.2010 15:21, Andreas Schneider wrote:
> You could use TIOStream from the unit iostream. AFAICS that should do
> exactly what you want - i.e. opening stdin/out/err as a TStream
> descendant.
> I don't know however, if that fixes the problem you have with the
> stream blocking when nothing is to be read.

TIOStream seems to work the same way on linux and windows (I tested only
with wine but it worked) ...and it will block.

It seems I really have to do the receiving of the data in a separate
thread.

(I wanted to avoid this because the things that must be done after
reading the data must be done in the main thread (it's a GUI
application) and now I have to fiddle around with synchronize & friends
instead of a simple method call which is not nice because I also have to
immediately answer the messages on stdout in a synchronous manner with
information received from the GUI. Polling on idle from the GUI thread
would have been so much more simple and elegant.)

Bernd



More information about the fpc-pascal mailing list