From 5abdeb283de7f4705b0f4ea62fa459e9a0d87872 Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Wed, 20 Jun 2012 10:27:24 -0400 Subject: [PATCH] Now properly handles a KILL process while running in Daemon mode --- mystic/mis.pas | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/mystic/mis.pas b/mystic/mis.pas index e0c3b01..3032dbe 100644 --- a/mystic/mis.pas +++ b/mystic/mis.pas @@ -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;