Re: SetConsoleCtrlHandler
- From: Steve Lawrence <sl516720@xxxxxxx>
- Date: Fri, 25 Aug 2006 03:38:01 -0700
Dear Gary / Ken,
First of all the system isn't shutting down, just the application. The
application isn't a service and is not associated with a console. It is
started up by some middleware called Top End. This is transaction control
software bought by BEA from NCR and merged with Tivoli. Tivoli lives on
because it is more well known and Top End was killed by BEA. Thus no support
and no W2K version.
The customer has tried to keep the W2K box the same as the NT 4 machine
apart from the OS itself and applications which have a release update for W2K
which don't run on NT. The application I'm having problems with is started by
Top End and does a SetConsoleCtrlHandler as almost it's first command. It
then sets up some additional event and sits waiting for something to happen.
I put some debug in to print to a file everything an event was caught by the
module. On NT the module never catches the console logoff, but on W2K it
catches it straight away (when the console is logged off) and commences
shutting down the application. As far as you know isn't there any difference
in this area between NT 4 and W2K? I'm wondering if it is worthwhile opening
a paid query with Microsoft or if it would just be a waste of time.
What I probably will do is just receive the event and ignore it if all else
fails.
Thanks for taking the time with this query.
--
Steve Lawrence
NCR Limited
London UK
NW1 6LY
"Skywing [MVP]" wrote:
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
- Follow-Ups:
- Re: SetConsoleCtrlHandler
- From: Skywing [MVP]
- Re: SetConsoleCtrlHandler
- References:
- Re: SetConsoleCtrlHandler
- From: Skywing [MVP]
- Re: SetConsoleCtrlHandler
- Prev by Date: Re: How to change process memory quotas
- Next by Date: Re: interactive service not capturing keystrokes through hooks
- Previous by thread: Re: SetConsoleCtrlHandler
- Next by thread: Re: SetConsoleCtrlHandler
- Index(es):
Relevant Pages
|