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.
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel