On Thu, 14 Dec 2023, Martin Frb via fpc-devel wrote:

If I am right the TProcess currently does not allow redirection of StdOut/In to/from a file (or other handle provided).

If it does, and I have been missing the "how to", then please enlighten me and disregard the remainder of the mail.

It does not exist out in the open :-)



The code for setting up redirection to pipes (to be read/write by the parent process) already exists. So this is mainly a call to add properties to explicitly set those handles.
Or provide some other method.

Is this something that should be added? (I.e. a feature request to be added)
If yes, should there just be 3 properties for the handles? A callback to create/provide them? A virtual method?
Should there be a flag?

Actually, I already started an implementation of an extension half a year ago.
(although I have the design in mind since several years. Time constraints...)

It's nearly finished, there are still some corner cases that need testing.

The idea is a property of type TIODescriptor (reduced code for readability):

TIOType = (iotNone,iotPipe,iotFIle,iotHandle,iotProcess);

TIODescriptor = class(Tpersistent)
Public
  Property Handle : THandle;
Published
  property IOType: TIOType;
  property FileName : string;
  property OnGetHandle : TGetHandleEvent;
property Process : TProcess; end;

uses as

TProcess = Class()
// ...
Published
  Property InputDescriptor : TIODescriptor;
  Property OutputDescriptor : TIODescriptor;
  Property ErrorDescriptor : TIODescriptor;
end;


What should be the resolving order if handles are give, but other flags (pipes/input) are set?

Backwards compatibility first and foremost. Setting the poUsePipes option
switches all descriptors to IOType = iotPipe.

I'll see if I can finish the implementation ASAP.

Michael.

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to