projects
/
mgsmtp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Catch CTRL-C event in user mode
[mgsmtp.git]
/
MgSMTP.pas
diff --git
a/MgSMTP.pas
b/MgSMTP.pas
index b172a1017abcce5a9bbf3cefcd84a40218a87d29..1cee11968ec66ea4e05e193e5620f9e3193102da 100644
(file)
--- a/
MgSMTP.pas
+++ b/
MgSMTP.pas
@@
-1,6
+1,6
@@
{
MegaBrutal's SMTP Server (MgSMTP)
{
MegaBrutal's SMTP Server (MgSMTP)
- Copyright (C) 2010-201
5
MegaBrutal
+ Copyright (C) 2010-201
6
MegaBrutal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@
-49,7
+49,7
@@
const
document what bugfix/feature are you testing with the actual build.
This will be logged to help you differentiate outputs of subsequent
builds in your logs. If left empty, it won't be added to the logs. }
document what bugfix/feature are you testing with the actual build.
This will be logged to help you differentiate outputs of subsequent
builds in your logs. If left empty, it won't be added to the logs. }
- DEVCOMMENT = '
Detect unexpected disconnection
';
+ DEVCOMMENT = '
Catch CTRL-C in user mode
';
var
var
@@
-130,6
+130,16
@@
begin
end;
end;
end;
end;
+function ConsoleCtrlHandler(Signal: dword): longbool; stdcall;
+{ Handle CTRL-C event in user mode. }
+begin
+ if Signal = CTRL_C_EVENT then begin
+ Out.writeln('Caught CTRL-C signal.');
+ Stopping:= true;
+ end;
+ Result:= true;
+end;
+
procedure Service(Argc: dword; Argv: pointer); stdcall;
var ProposedExitCode: integer;
begin
procedure Service(Argc: dword; Argv: pointer); stdcall;
var ProposedExitCode: integer;
begin
@@
-302,6
+312,7
@@
begin
else begin
if Cmdline.IsPresent('USERMODE') then begin
Out.writeln('Starting MgSMTP in user mode...');
else begin
if Cmdline.IsPresent('USERMODE') then begin
Out.writeln('Starting MgSMTP in user mode...');
+ SetConsoleCtrlHandler(ConsoleCtrlHandler, true);
Service(0, nil);
end
else begin
Service(0, nil);
end
else begin