ocra icon indicating copy to clipboard operation
ocra copied to clipboard

When run as service: Leaves ruby running and temp directory in place

Open alfmar opened this issue 14 years ago • 2 comments

On Windows Server 2008, if the ocra-generated EXE file is started as a service using SRVANY.EXE, when the service is stopped/killed, the ruby.exe/rubyw.exe continues running.

Killing the ruby.exe/rubyw.exe does not automatically clear the temporary directory hierarchy.

Is this a SRVANY.EXE problem or an OCRA problem?

alfmar avatar Dec 23 '10 16:12 alfmar

Lets call it an OCRA deficiency. It can be handled by OCRA. I'll look into it.

larsch avatar Dec 23 '10 20:12 larsch

I appears that Windows provide no method to trap kill signals. I only know only one way:

  1. Implement a service stub as alternative to the default main stub, which is based on the Windows' service API. Then the executable can be registered as a service on its own and will be notified of stop requests.

It probably possible to make the default stub slightly more robust by creating a message-only window and handling the WM_CLOSE message. However, this will still not help when running from SRVANY.EXE, nor when being terminated from the Process Explorer. WM_CLOSE appears to be the "official" method for terminating a process while giving it a chance to clean up, even for applications without windows (except services of course).

larsch avatar Jan 23 '11 11:01 larsch