I converted a Delphi windows application to freepascal daemon to run on linux.
I am using the lazdaemonapp and daemonapp code
The app was throwing an AccessViolation error every time i would send a killall -SIGTERM command.
After many hours I went back to base and created a new application with no code in it apart from DaemonApplication, DaemonMapper and DaemonApp code ran it and get the access violation message in syslog and this on the command line
$ ../temp/daemonexample/project1 -r
Exception at 0000000000000000: EAccessViolation:
Access violation.
Has anyone else used the apps and had any issues?
FreePascal=3.0.4
Lazarus=2.0.6
OS=Ubuntu 20.10
This is basically all the code
Project
Program project1;
Uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
CThreads,
{$ENDIF}{$ENDIF}
DaemonApp, lazdaemonapp, DaemonMapperUnit1, DaemonUnit1
{ add your units here };
begin
Application.Initialize;
Application.Run;
end.
Mapper
unit DaemonMapperUnit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, DaemonApp;
type
{ TDaemonMapper1 }
TDaemonMapper1 = class(TDaemonMapper)
procedure DaemonMapper1Create(Sender: TObject);
private
public
end;
var
DaemonMapper1: TDaemonMapper1;
implementation
procedure RegisterMapper;
begin
RegisterDaemonMapper(TDaemonMapper1)
end;
{$R *.lfm}
{ TDaemonMapper1 }
procedure TDaemonMapper1.DaemonMapper1Create(Sender: TObject);
var
D : TDaemonDef;
begin
D:=DaemonDefs.Add as TDaemonDef;
D.DisplayName:='Test Service daemon';
D.Name:='TestServiceDaemon';
D.DaemonClassName:='TDaemon1';
end;
initialization
RegisterMapper;
end.
App
unit DaemonUnit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, DaemonApp;
type
TDaemon1 = class(TDaemon)
private
public
end;
var
Daemon1: TDaemon1;
implementation
procedure RegisterDaemon;
begin
RegisterDaemonClass(TDaemon1)
end;
{$R *.lfm}
initialization
RegisterDaemon;
end.