Now properly handles a KILL process while running in Daemon mode

This commit is contained in:
mysticbbs 2012-06-20 10:27:24 -04:00
parent 96d35e9af6
commit 5abdeb283d
1 changed files with 19 additions and 1 deletions

View File

@ -429,12 +429,28 @@ Begin
End; End;
End; End;
Procedure DaemonEventSignal (Sig : LongInt); cdecl;
Begin
Case Sig of
SIGTERM : Begin
TelnetServer.Free;
SMTPServer.Free;
POP3Server.Free;
FTPServer.Free;
NNTPServer.Free;
NodeData.Free;
Halt(0);
End;
End;
End;
Procedure ExecuteDaemon; Procedure ExecuteDaemon;
Var Var
PID : TPID; PID : TPID;
SID : TPID; SID : TPID;
Begin Begin
WriteLn('- Executing Mystic Internet Server in daemon mode'); WriteLn('- [MIS] Executing Mystic Internet Server in daemon mode');
PID := fpFork; PID := fpFork;
@ -454,6 +470,8 @@ Begin
Halt(1); Halt(1);
End; End;
fpSignal (SIGTERM, DaemonEventSignal);
Repeat Repeat
WaitMS(60000); // Heartbeat WaitMS(60000); // Heartbeat
Until False; Until False;