Mail Archives: cygwin/2008/10/18/14:07:38
> Maybe you need to call SetServiceStatus(SERVICE_STOPPED) or exit the
> process or something? What happens when you use net stop to stop the
> service? It stops reasonably fast, or not?
Stopping the service manually is always fast. As for your suggestion to
exit the process: it is not what we want. The service in question is a
webserver and we want to keep it running when the user logs off.
According to http://msdn.microsoft.com/en-us/library/ms683242(VS.85).aspx:
[snip]
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.
[snap]
Corinna had written a test that always returned TRUE. This means (unless
there was another handler installed, or some weird 32-to-64-bit TRUE
conversion occured etc.) the OS should consider CTRL_LOGOFF_EVENT as
handled and should not do any additional processing. Yet, the behaviour
seems surprisingly similar to the following...
[snip]
"Return TRUE. In this case, no other handler functions are called, and
the system displays a pop-up dialog box that asks the user whether to
terminate the process. The system also displays this dialog box if the
process does not respond within a certain time-out period (5 seconds for
CTRL_CLOSE_EVENT, and 20 seconds for CTRL_LOGOFF_EVENT or
CTRL_SHUTDOWN_EVENT)."
[snap]
If it really a bug in the OS, it should also apply to any other
console-based service. I plan to investigate this when I have time.
S
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -