Recent

Author Topic: TProcess freeze  (Read 335 times)

LemonParty

  • Full Member
  • ***
  • Posts: 204
TProcess freeze
« on: June 12, 2025, 04:07:43 pm »
I have this code, that by design should compile several units:
Code: Pascal  [Select][+][-]
  1.   P.Executable:= CFPC;
  2.   P.Options:= P.Options + [poWaitOnExit, poUsePipes];
  3.  
  4.   Writeln('---32 bit targets---');
  5.   for i:= 0 to High(CUnitNames) do begin
  6.     Write('  COMPILING ', CUnitNames[i]);
  7.     P.Parameters[0]:= CUnitNames[i];
  8.     P.Execute;
  9.     SL.LoadFromStream(P.Output);
  10.     if P.ExitCode = 0
  11.       then Writeln(' OK')
  12.       else Writeln(SL.Text);
  13.   end;
P is TProcess, SL – TStringList. When I run this code it freeze at P.Execute. What the problem?
« Last Edit: June 12, 2025, 04:10:58 pm by LemonParty »
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12340
  • FPC developer.
Re: TProcess freeze
« Reply #1 on: June 12, 2025, 04:26:24 pm »
Search for large output here, and implement it.

https://wiki.freepascal.org/Executing_External_Programs

LemonParty

  • Full Member
  • ***
  • Posts: 204
Re: TProcess freeze
« Reply #2 on: June 12, 2025, 05:01:28 pm »
No, still freeze.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12340
  • FPC developer.
Re: TProcess freeze
« Reply #3 on: June 12, 2025, 05:05:03 pm »
Then you maybe need stderr processing too, see implementation of runcommandloop. (or use runcommand)

LemonParty

  • Full Member
  • ***
  • Posts: 204
Re: TProcess freeze
« Reply #4 on: June 12, 2025, 05:47:18 pm »
I solved this by using RunCommandInDir this way:
Code: Pascal  [Select][+][-]
  1. RunCommandInDir('', CFPC, RunSwitches, Output, ExitCode)
RunCommandInDir by default wait until process finish.
Thank you for help.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

 

TinyPortal © 2005-2018