Re: SetConsoleCtrlHandler



This is the expected behavior for services as far as I know. I don't know
of any OS setting to disable that event.

"CTRL_LOGOFF_EVENT (5) A signal that the system sends to all console
processes when a user is logging off. This signal does not indicate which
user is logging off, so no assumptions can be made.
Note that this signal is received only by services. Interactive applications
are terminated at logoff, so they are not present when the system sends this
signal.

[...]

When a console application is run as a service, it receives a modified
default console control handler. This modified handler does not call
ExitProcess when processing the CTRL_LOGOFF_EVENT and CTRL_SHUTDOWN_EVENT
signals. This allows the service to continue running after the user logs
off. If the service installs its own console control handler, this handler
is called before the default handler. If the installed handler calls
ExitProcess when processing the CTRL_LOGOFF_EVENT signal, the service exits
when the user logs off.

Note that a third-party library or DLL can install a console control handler
for your application. If it does, this handler overrides the default
handler, and can cause the application to exit when the user logs off."



Is it possible that you had something else loaded in your process on NT4
that was eating the CTRL_LOGOFF_EVENT, and that something is no longer being
used on Win2k?


--
Ken Johnson (Skywing)
Windows SDK MVP

"Steve Lawrence" <sl516720@xxxxxxx> wrote in message
news:99023D0F-0BFA-4DFA-A71F-CCD11F4F7B9E@xxxxxxxxxxxxxxxx
Dear Microsoft Support,

I have posted this problem to the W2K migration newsgroup and they
recommended I post it here instead. I hope this is the correct place. It
is
concerning a difference in results when using the above API.

My company has a customer who is attempting to run a package we released
on
NT 4 Server years ago now on a W2K Server. We stopped supporting the
package
some time ago, but told them we would make our best efforts to help them
with
no promises. The reason for this OS move is the fact that their hardware
supplier can no longer provide NT 4 compliant hardware.

The customer carried out testing successfully on W2K and installed it in a
live site. On the first day the application started shutting itself down.
Eventually it was traced down to the fact that it was shutting down when
the
console logged off. The customer stopped users from logging off on the
console and asked me what the problem was.

I obtained the source from our home office in the US (I'm in the UK.) for
examination. When the application starts up to uses the API
SetConsoleCtrlHandler and when this event is received, it shuts down. On
NT 4
Server this event is never triggered and the program is not effected. On
W2K
the event is triggered and the program initiates a shutdown.

What is the difference between W2K in NT in this area. Our ideal solution
would be to change a setting in the OS. This is because I'm not sure I
have
all the proper libraries, etc. to trust a recompile and ignore this event.
The person who put in the event handler is also not available to query why
it
was done this way in the first place.

Thanks in advance for your help.

Regards,

Steve Lawrence


--
Steve Lawrence
NCR Limited
London UK
NW1 6LY



.



Relevant Pages

  • Re: SetConsoleCtrlHandler
    ... console logoff events. ... This modified handler does not call ... signals. ... This allows the service to continue running after the user logs ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Using SetConsoleCtrlHandler
    ... "bare minimum" principal should work even in multithreaded POSIX apps, ... you rely on recursive lock acqusition in your "signal handler" - hard to ... POSIX signals to POSIX processes". ... "Kernel mode APCs interrupt a thread and execute a procedure without ...
    (microsoft.public.win32.programmer.kernel)
  • Re: pitfalls of signals
    ... If you have a signal handler that was invoked as a result of your program ... in that case you've invoked undefined behavior ... without invoking undefined behavior ... -Temporarily block a set of signals that includes the one the handler ...
    (comp.lang.c)
  • Re: Mars Rover Controlled By Java
    ... When handling signals Ada provides a higher level abstraction that ... -- Defines the interface for a signal handler ... task Responder is ... interrupt is handled only once. ...
    (comp.programming)
  • Re: Using SetConsoleCtrlHandler
    ... Assuming the signal handler does the minimum (ie. set a global, ... Only a single-threaded POSIX ... POSIX signals to POSIX processes". ... "Kernel mode APCs interrupt a thread and execute a procedure without the ...
    (microsoft.public.win32.programmer.kernel)