[fpc-devel] Console IO revisited

Michael Van Canneyt michael at freepascal.org
Fri Dec 3 13:38:32 CET 2010



On Fri, 3 Dec 2010, Thaddy wrote:

> Sorry if this is already picked up as it IMHO should have been. I missed some 
> mails due to a server crash.
>
> Today I encountered a similar issue with using threadvars for the input, 
> output and err variables in system when trying to use the input as a win32 
> sync handle with the CreateFile API. Fails miserably.
> This is specified in the windows API documentation, but is broken in FPC 
> because the IO are not global to a process but threadvar.

Would you care to explain this ?

The variables Input, Output and StdErr may be threadvars, but they share a 
single common OS handle. So any OS-specific functions should still work if 
you are using the handles.

If you are attempting to translate some concepts that work on handles to 
Pascal files, then you should be warned that they will fail in each case, 
because file handling works with internal buffers - threadvars or not.

The variables Input, Output and StdErr have been made threadvars so the 
basic pascal functions ReadLn and Writeln are thread-safe.

As for Posix: Pascal is not Posix; We define the RTL as we see fit; 
So invoking non-posix compliance is not an argument.

So please explain your problem properly and detailed.

Michael.



More information about the fpc-devel mailing list