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;
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;
Var
PID : TPID;
SID : TPID;
Begin
WriteLn('- Executing Mystic Internet Server in daemon mode');
WriteLn('- [MIS] Executing Mystic Internet Server in daemon mode');
PID := fpFork;
@ -454,6 +470,8 @@ Begin
Halt(1);
End;
fpSignal (SIGTERM, DaemonEventSignal);
Repeat
WaitMS(60000); // Heartbeat
Until False;