[fpc-devel] StdOut capture for FPC RTL

Michael Van Canneyt michael at freepascal.org
Wed Nov 24 21:32:54 CET 2010



On Wed, 24 Nov 2010, Anton Kavalenka wrote:

> Dear All.
> 
> Currently to implement logger we use the following approach (the code was implemented for Delphi/Kylix/FPC).
> Logger is intended for displaying in the GUI outputs of several threads and child processes and also for storage into internal bases.
> 
> Logic is the following:
> 
> Get stdout handle (duplicate it under linux),
> create pipe,
> replace the stdout (keeping the old stdout) for current process with write handle of pipe,
> 
> There are following problems with FPC
> Under Windows: I have to call rewrite(output) for every thread which wants to useĀ  new (captured) stdout
> 
> So the questions:
> How to force all the threads of process and all DLLs write into same captured stdout?

There is no way that I know of to avoid the rewrite(), since the file descriptor 
records for Input, Output and StdErr are threadvars. 
And the threadvars must be initialized on thread start.

> How to revert stdout back (stop capturing)?

Close and reopen using the standard filedescriptors ?

Michael.


More information about the fpc-devel mailing list