Skip to content

Commit

Permalink
improve systemd detection in ProcessIsStartedBySystemd
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel.mash committed Jun 23, 2020
1 parent 0f9e495 commit 325e10e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion SynSystemd.pas
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ function ProcessIsStartedBySystemd: boolean;
begin
if not SystemdIsAvailable then
exit(false);
Result := fpGetenv(ENV_INVOCATION_ID) <> nil;
// note: for example on Ubuntu 20.04 INVOCATION_ID is always defined
// from the other side PPID 1 can be in case we run under docker of started by init.d
// so let's verify both
Result := (fpgetppid() = 1) and (fpGetenv(ENV_INVOCATION_ID) <> nil);
end;

procedure LibSystemdInitialize(const libname: TFileName);
Expand Down

0 comments on commit 325e10e

Please sign in to comment.