Basierend auf diesem Beitrag: viewtopic.php?t=14256 habe einen killall handler in meiner Anwendung, seit neuestem bekomme ich aber eine Zugriffsverletzung in der Anwendung wenn von außen das Killall kommt
Im Anhang noch mal eine Demo mit der man es nachstellen kann.Project demo raised exception class 'External: SIGTERM'.
In file '../sysdeps/unix/sysv/linux/poll.c' at line 29
Code: Alles auswählen
Program demo;
{$MODE objfpc}{$H+}
Uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
{$IFDEF HASAMIGA}
athreads,
{$ENDIF}
Interfaces, // this includes the LCL widgetset
{$IFDEF LINUX}
BaseUnix,
{$ENDIF}
Forms, unit1
{ you can add units after this };
{$R *.res}
{$IFDEF LINUX}
Procedure DoKill(Signal: CInt); cdecl;
Begin
If Signal = SIGTERM Then Begin
writeln('Going down through sigkill..');
form1.Close;
End;
End;
Procedure InstallSigHandler;
Var
Action: PSigActionRec;
Begin
New(Action);
Action^.sa_handler := SigActionHandler(@DoKill);
FillChar(Action^.sa_mask, SizeOf(Action^.sa_mask), #0);
Action^.sa_flags := 0;
Action^.sa_restorer := Nil;
If FPSigaction(SIGTERM, Action, Nil) <> 0 Then Begin
WriteLn('Error: ', fpgeterrno);
Halt(1);
End;
Dispose(Action);
End;
{$ENDIF}
Begin
{$IFDEF LINUX}
InstallSigHandler;
{$ENDIF}
RequireDerivedFormResource := True;
Application.Scaled := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
End.