From 57f9db6cc0eb31806d4ec65cd870e49f8b528c1f Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Sun, 8 May 2016 17:57:08 -0700 Subject: [PATCH] dll: FspService: console mode improvements --- src/dll/service.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dll/service.c b/src/dll/service.c index 38aaaec6..98e805b2 100644 --- a/src/dll/service.c +++ b/src/dll/service.c @@ -482,17 +482,15 @@ static DWORD WINAPI FspServiceConsoleModeThread(PVOID Context) static BOOL WINAPI FspServiceConsoleCtrlHandler(DWORD CtrlType) { - if (0 != FspServiceConsoleModeEvent) - SetEvent(FspServiceConsoleModeEvent); - switch (CtrlType) { default: case CTRL_C_EVENT: case CTRL_BREAK_EVENT: + if (0 != FspServiceConsoleModeEvent) + SetEvent(FspServiceConsoleModeEvent); return TRUE; case CTRL_CLOSE_EVENT: - case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: /* * Returning from these events will kill the process. OTOH if we do not return timely @@ -500,11 +498,16 @@ static BOOL WINAPI FspServiceConsoleCtrlHandler(DWORD CtrlType) * to give the process some time to cleanup itself. * * We only do so if we have a Close event or we are interactive. If we are running as - * a service the OS will not kill us after delivering a Logoff or Shutdown event. + * a service the OS will not kill us after delivering a Shutdown (or Logoff) event. */ + if (0 != FspServiceConsoleModeEvent) + SetEvent(FspServiceConsoleModeEvent); if (CTRL_CLOSE_EVENT == CtrlType || FspServiceIsInteractive()) Sleep(30000); return TRUE; + case CTRL_LOGOFF_EVENT: + /* services should ignore this! */ + return TRUE; } }