diff options
Diffstat (limited to 'unit1.pas')
-rw-r--r-- | unit1.pas | 40 |
1 files changed, 38 insertions, 2 deletions
@@ -63,12 +63,13 @@ function wertZuX(w: extended; startZeit,stopZeit: extended; breite: longint): lo function wertZuY(w: extended; miMa: tPoint; hoehe: longint): longint; inline; overload; function wertZuY(w: extended; miMa: tExtPoint; hoehe: longint): longint; inline; overload; function wertZuY(w: extended; mi,ma: extended; hoehe: longint): longint; inline; overload; +procedure SignalCapture(signal : longint); cdecl; implementation {$R *.lfm} -uses process, myStringListUnit, systemUnit, matheunit, math; +uses process, myStringListUnit, systemUnit, matheunit, math, baseUnix; { TForm1 } @@ -78,6 +79,7 @@ var f,o: tMyStringList; fi: textfile; args: array of string; + na: pSigActionRec; begin fehler:=true; __ausgabenMaske:=1; @@ -150,12 +152,29 @@ begin end; f.free; - fehler:=false; + new(na); + na^.sa_Handler := sigActionHandler(@signalCapture); + fillchar(na^.sa_Mask,sizeof(na^.sa_mask),#0); + na^.sa_Flags := 0; + {$ifdef Linux} // Linux specific + na^.sa_Restorer := Nil; + {$endif} + if (fPSigaction(SIGUSR1, na, nil) <> 0) or + (fPSigaction(SIGTERM, na, nil) <> 0) or + (fPSigaction(SIGINT, na, nil) <> 0) then begin + writeln('Fehler beim Signalempfängerreservieren: '+inttostr(fpgeterrno)+'.'); + raise exception.create('Fehler beim Signalempfängerreservieren: '+inttostr(fpgeterrno)+'.'); + end; + dispose(na); + zeichnen; + fehler:=false; end; procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction); begin + form1.visible:=false; + trayIcon1.visible:=false; pegel.putBeenden; wetter.mutBeenden; end; @@ -274,5 +293,22 @@ begin result:=hoehe-1-round((w-mi)/(ma-mi)*(hoehe-2)); end; +procedure SignalCapture(signal : longint); cdecl; +begin + case signal of + SIGUSR1: begin + writeln('received SIGUSR1!'); + if assigned(form1.pegel) and (form1.pegelDatei<>'') then + form1.pegel.speichern(form1.pegelDatei); + if assigned(form1.wetter) and (form1.wetterDatei<>'') then + form1.wetter.speichern(form1.wetterDatei); + end; + SIGTERM,SIGINT: begin + writeln('received SIGTERM/SIGINT!'); + form1.close; + end; + end{of case}; +end; + end. |