Hi.
Lazarus-1.2.6 w/fpc-2.6.4 on clean install Slackware64 14.1 ( I had unexplainable issues, so I formated/reinstalled &
so far everything is repeatable)
This is my issue:
I am attempting to use TProcess (with "Run detached program" example from "
http://wiki.freepascal.org/Executing_External_Programs#Run_detached_program" ) to have ProgramA start & run ProgramB. ProgramB is
to keep running regardless if ProgramA shuts down. But these are my results :
1/ ProgramA started from within Lazarus, Result : ProgramB started by ProgramA runs correctly, but shuts down
when ProgramA shuts down ( terminal command "ps -A" shows both programs as "pts");
2/ ProgramA started from "File Manager", Result : ProgramB does not start correctly, "ps -A" shows
"tty ProgramB <defunct>" & ProgramB disappears from "ps -A" list when ProgramA is shut down.
3/ ProgramA is started from Terminal with "./ProgramA", Result : All works as I wanted, ProgramB is started by ProgramA, and stays running even after ProgramA and Terminal are shutdown.
First, are these the results I should be expecting? Second is it possible to get #3's results without launching a terminal (#2) ?
Thanks, Frank
ps, Here is my code...
{
################### Run Program, ShellExecute Replacement ###################
}
Procedure linuxShellExecute(ExeName : String);
var
Process: TProcess;
I: Integer;
begin
Process := TProcess.Create(nil);
try
Process.InheritHandles := False;
Process.Options := [];
Process.ShowWindow := swoShow;
// Copy default environment variables including DISPLAY variable for GUI application to work
for I := 0 to GetEnvironmentVariableCount - 1 do
Process.Environment.Add(GetEnvironmentString(I));
// Process.Executable:= ExeName;
Process.Executable:= '/usr/bin/kwrite';
Process.Execute;
finally
Process.Free;
end;
end;