Recent

Author Topic: TProcess and lots of data (100 kB)  (Read 526 times)

domasz

  • Sr. Member
  • ****
  • Posts: 379
TProcess and lots of data (100 kB)
« on: November 30, 2023, 06:33:14 pm »
I want to run in background a command line program and capture output. The code below works for files (specified by Filename) < 1 kB but for files > 10 kB it just freezes. "dumper.exe" simply reads and outputs file, nothing fancy here.

Code: Pascal  [Select][+][-]
  1.   Process := TProcess.Create(nil);
  2.   Process.Options := Process.Options + [poWaitOnExit, poUsePipes, poNoConsole];
  3.   Process.Executable := 'dumper.exe';
  4.   Process.Parameters.Add(Filename);
  5.   Process.Runcommandloop(StdOut, StdErr, Status);
  6.   Result := StdOut;
  7.   Process.Free;

Attached the whole application
« Last Edit: November 30, 2023, 08:01:10 pm by domasz »

domasz

  • Sr. Member
  • ****
  • Posts: 379
Re: TProcess and lots of data (100 kB)
« Reply #1 on: November 30, 2023, 07:53:31 pm »
And here's full source code of the "dumper.exe"

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11261
  • FPC developer.
Re: TProcess and lots of data (100 kB)
« Reply #2 on: November 30, 2023, 10:12:58 pm »
Remove powaitonexit. That forces it to wait till completion even while piping.

domasz

  • Sr. Member
  • ****
  • Posts: 379
Re: TProcess and lots of data (100 kB)
« Reply #3 on: December 01, 2023, 10:33:32 am »
Thank you!

 

TinyPortal © 2005-2018