in reply to SrvAny based Win32 service: how to catch termination?

Service "events" (Service Control Requests) are sent from the Service Control Manager to the main thread of the service (through a named pipe), where a control handler should be registered. This control handler function is executed on receipt of the Service Control Request. The application itself runs in a separate thread (known as "service main"). I honestly can't see how SrvAny could provide that functionality to a single-threaded non-service app. It probably just provides scafolding. There is no way it would use signals anyhow - they are UNIX architecture and poorly implemented on Windows (to conform to ISO C standards, no more).

From the SrvAny documentation:

"WARNING: When the service is stopped, it terminates the application via the WIN32 TerminateProcess() API: this is a drastic way to end an application. For example, it would not allow the application to prompt the user to save changes. Therefore, it is recommended to close the application BEFORE stopping the service."

Which kinda confirms my guesses above.

Update: I came across a 5.10 version of Win32::Daemon. Can't say I have tried it, but it might help. See the link and explaination here
  • Comment on Re: SrvAny based Win32 service: how to catch termination?

Replies are listed 'Best First'.
Re^2: SrvAny based Win32 service: how to catch termination?
by dolmen (Beadle) on Sep 11, 2009 at 15:03 UTC

    I'm aware of this 5.10 release (as I said in my question). But it is only a binary only release.

    I do not want to rely on a Perl module for which I do not have the source.

    And about SrvAny, you killed the little hope I had I missed something. :(