<update> Sorry, didn't notice this was a MacOS/cocoa specific problem. Code example below should be adapted to call an application available in cocoa...</update>
To test if the launched process is still running after AProcess.Execute:
program project1;
uses process;
var AProcess: TProcess;
begin
AProcess := TProcess.Create(nil);
AProcess.Executable := 'C:\Windows\System32\cmd.exe';
AProcess.Parameters.Text := '/k';
AProcess.Options := [poWaitOnExit, poNewConsole];
AProcess.Execute;
if AProcess.Running then
writeln('Error - launched process still running.')
else
writeln('OK - launched process not running.');
AProcess.Free;
end.
This example waits correctly (in Windows) until one closes the console opened by cmd.exe. Tested with FPC 3.0.4 (64 bit) on Windows 10. skalogryz gave two very valid scenarios that could explain your observation. Could you give more detail of your setup (OS, external application name, fpc version)? Also, can you see that the
original launched process is still running (by checking the launched process command line in
e.g. task manager, ps, top etc.Activity Monitor) after AProcess.Execute returns?