Linux does not kill a process just because the parent process died. But any child process inherits the output stream of the parent process, which goes to the same terminal. So what you are probably experiencing is that the terminal closes and thereby either closes the application through the hang up signal (SIGHUP) or because the input/output/error stream got closed and this causes an error when trying to write to it.
This can be circumvented with the nohup utility, as written previously, but I feel that I have to warn you, to avoid calling either fpsystem or using TProcess for calling bash. There is absolutely no reason to start up a full scale scripting language interpreter (like bash) for such a simple task. In fact, depending on what inputs you give it (e.g. arguments from user input) this can be a security risk.
nohup already redirects the output to a file, no need to call bash at all for file redirection.
If the process you start doesn't produce output, you don't even need nohup, you can also very easiely do it yourself. Nohup does nothing else than simply calling
signal to set SIGHUP on ignore, before executing the target process. In your programm you can simply before starting the process set SIGHUP to ignore, start the process (which inherits the signal handling configuration) and then revert it afterwards back to normal for your main program.
If you want to log the output and have nohup functionality without relying on nohup, this is also quite simple, you just need to do the fork execvp yourself. Not tested, but it should look like this:
procedure RunDetached(Exec: String; Args: TStringArray; const OutputFile: String);
var
fs: TFileStream;
begin
if fpFork <> 0 then Exit; // Parent process can return
fs := TFileStream.Create(OutputFile, fmCreate);
try
fpdup2(fs.Handle, StdOutputHandle); // Redirect output to file
fpdup2(fs.Handle, StdErrorHandle); // Redirect error output to file
finally
fs.Free;
end;
SetLength(Args, Length(Args) + 1); // Must be 0 terminated
fpSignal(SIGHUP, SIG_IGN); // Ignore Terminal closing signal
// Execute process
fpexecvp(PChar(Exec), PPChar(Args));
end;
nohup isn't doing pretty much anything different (well it has more error handling but this is just proof of concept), so this is extremely simple to do