[fpc-devel] StdOut capture for FPC RTL

Thaddy thaddy at thaddy.com
Fri Nov 26 03:06:21 CET 2010


On 25-11-2010 18:57, Jonas Maebe wrote:
>
> Actually, that won't work because the different threads will then work on a common buffer but with distinct pointers into it. A better solution is probably to do this in the intialisation code of each thread instead:
>
> {$ifdef unix}
>    fpclose(ttextrec(stdout).handle);
> {$elsif defined(MSWINDOWS)}
>    { this is a copy of do_close() from the rtl, I don't know whether
>      a new handle from a thread can actually have any of these values }
>    if (handle<>  StdInputHandle) and
>       (handle<>  StdOutputHandle) and
>       (handle<>  StdErrorHandle) then
>      CloseHandle(ttextrec(stdout).handle);
> {$else}
>    {$error Add support for this platform}
> {$endif}
>
> ttextrec(stdout).handle:=myglobalstdouthandle;
>
>
> Jonas_______________________________________________
>
This is the world upside down. Both for nixes and windows, you would 
expect the streams on a per process basis, not per thread, and handle 
possible contention by code.
i.e. it is - should be - expected that they work on a common 
buffer/pointer by definition.




More information about the fpc-devel mailing list