I have written an editor which can be used like | more. In Windows, all works fine, but on Unix systems (Linux, MacOSX), it is not allowed to kill a thread from outside. This is necessary if the editor gets closed by the user.
The code in MyThread.Execute is
repeat
FileRead (stdin, BufferArea, 1);
{process the character which is hold in BufferArea[1]}
until DoEndThread;
DoEndThread is set from outside the thread, because in Unix systems, the Thread is not allowed to get killed from outside without being terminated by itself.
Now the problem is that if no stdin input is available, the thread sleeps in the FileRead procedure and does not reach the "until" condition to terminate the loop.
Is there a read procedure which returns immediately if nothing is to read at the moment? Or is there another solution?