[fpc-pascal] TProcess vs RunProcess()

Lars noreply at z505.com
Mon Jan 30 00:51:33 CET 2017

On Sun, January 29, 2017 3:18 am, Marco van de Voort wrote:
> In our previous episode, Lars said:
>> Assign(StdErr, 'somefile.txt')
>> Rewrite(StdErr)
>> And didn't seem to work
>> So if you run a process and nothing prints to stdout, and there is some
>>  data printed to stderr, I do not know how to capture it. Which makes
>> me want to try TProcess instead, but if I could do it with FpSystem and
>> ExecuteProcess that would be nice
> Executeprocess doesn't support piping. It orignally was mainly meant as a
>  portable dos.exec with parameters passed separately and without string
> length limits, implementable on RTL level.

But doesn't all processes report to stderr?
Ones that are created in a program do not report to stderr?

The OS makes it optional if you want to report to stderr?  Interesting..

Another idea is to modify AssignStream to work on windows as AFAIK it only
works on unix from the unix units of rtl..

function AssignStream(var StreamIn, StreamOut, StreamErr: Text; const
prog: String): LongInt;
  Starts the program in 'prog' and makes its input, output and error output
  the other end of three pipes, which are the stdin, stdout and stderr of a
  program specified in 'prog'.

^^^ very useful function!

Reason I want to avoid TProcess is simply because cgi programs being
around 30-100K are easier to upload for people with limited internet
connection speeds. As soon as I pull in large units that involve lots of
classes the cgi programs become over 200-500K.

However I will use tprocess if it's a time save, which indeed it is
instead of rewriting assignstream for windows.

Plus, golang cgi exe's are about 2MB in size, so golang ain't got anything
on fpc at this moment (fpc still creates small programs compared to GoLang
runtime programs!)

More information about the fpc-pascal mailing list