You are not logged in.
Hi!
mormot.core.os
  // - should return true to stop the execution, or false to continue
  .....
  // - the raw process ID (dword on Windows, cint on POSIX) is also supplied
  TOnRedirect = function(const text: RawByteString; pid: cardinal): boolean of object;
  // - will optionally call onoutput() to notify the new output state
  // - can abort if onoutput() callback returns false, or waitfordelayms expires
  ....
  function RunRedirect(const cmd: TFileName; exitcode: PInteger = nil;
Actually, it works fine as described for TOnRedirect. i.e. when the result is false then execution continue.
Offline
You are right.
Should be better with
https://github.com/synopse/mORMot2/commit/c2b0e3cc
Offline
As always, thanks for the lightning-fast response, ab! ))
Add.
Is it possible to add RedirectOutput execution after a certain timeout rather than after the buffer is full? 
For long processes with percentage progress, a lot of time passes until the buffer is filled out and the data is transferred to TOnRedirect.
Thanks!
Last edited by vs (2024-02-06 20:06:50)
Offline
On Linux/POSIX, it is running the TOnRedirect every 200 ms at most. OK.
On Windows, it indeed waits for its buffer to be filled.
I started in fact from https://stackoverflow.com/a/25725197/458259 code, which does wait for the full buffer to be filled.
Not what we expect for sure.
I guess it should do the trick:
https://github.com/synopse/mORMot2/commit/e6f42145
Offline
Thanks ab.
I tested, but the result is the same.
Offline
Offline
Humm, you are rigth. Testing with "ping" works fine.
But with small test program like
 
begin
  for i := 10 to 80 do
    begin
      write(IntToStr(i) + ',');
      sleep(200);
    end;
end. I get this log
Start at: 07.02.2024 19:54:58
OnRedirect at: 07.02.2024 19:55:06
10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52
OnRedirect at: 07.02.2024 19:55:12
,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,
Exit Code: 0function TFoo.OnRedirect(const text: RawByteString; pid: cardinal): boolean;
begin
  Result := False;
//  Writeln(pid);
  if text <> '' then
    begin
      Writeln('OnRedirect at: ' + DateTimeToStr(Now));
      Writeln(text);
    end;
end;Last edited by vs (2024-02-07 18:00:10)
Offline