#1 2021-08-20 12:17:14

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

RunProcess/Command inside a Daemon

Hello,

A need to start a secondary console application inside the daemon, and not wait for execution.

When using RunProcess (or RunCommand) inside a daemon, the target application does not start and generates the error "File not open".

- Both Daemon App and Target dont uses Writeln.

- When running the very same Daemon as console (./mydaemon --console), works fine.

- When using Free Pascal native process.RunCommandIndir method works inside the Daemon, but dont have the option to "not wait".

procedure TDaemon.Start;  
try
   mormot.core.os.RunProcess('/home/ubuntu/app/targetapp', 'myParam', false);          
except
  on E : Exception do
      FileFromString('Error: ' + E.Message, 'error.txt');  //Write: File not open    
end;

Offline

#2 2021-08-20 12:46:34

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

Re: RunProcess/Command inside a Daemon

Solved with TProcess from FP.

Process := TProcess.Create(nil);
...
Process.InheritHandles := False;
Process.Options := [];
Process.ShowWindow := swoNone;
Process.Executable := '/home/ubuntu/app/targetapp';
Process.Parameters.Add('myParam');
Process.Execute;

Secondary app run detached.

Offline

Board footer

Powered by FluxBB