public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Windows Restart Manager and cygrunsrv services
@ 2020-01-23 17:44 Bill Stewart
  2020-01-27 16:20 ` Bill Stewart
  0 siblings, 1 reply; 3+ messages in thread
From: Bill Stewart @ 2020-01-23 17:44 UTC (permalink / raw)
  To: cygwin

Good day,

Application installers (such as Windows Installer or Inno Setup) can
use the Windows Restart Manager APIs[1] it to determine if a program
or service is running, and automatically stop/restart as appropriate.

This is useful when reinstalling or upgrading a service from an
installer, as the installer itself can stop the service, replace the
binary/binaries, and restart the service automatically.

However it seems that when running a service using cygrunsrv, the
Restart Manager RmGetList API[2] returns RmRebootReasonSessionMismatch
(2) for the lpdwRebootReasons output parameter.

This parameter return value is one of the RM_REBOOT_REASON enumeration
values[3].

The description for the RmRebootReasonSessionMismatch value on MSDN is
as follows: "One or more processes are running in another Terminal
Services session."

I ran into this building an Inno Setup installer. I reproduced on
Windows 10 x64 and Windows Server 2008 R2 x64.

The error description is interesting, because in neither repro case
were there other users logged on using TS sessions. (I'm not sure if
that error description is completely accurate in describing all cases
where that value gets returned, though...)

Unexpected behavior: Restart Manager returns 2
(RmRebootReasonSessionMismatch) in the lpdwRebootReasons output
parameter when calling the RmGetList API to detect a cygrunsrv
service.

Expected behavior: Restart Manager should return 0
(RmRebootReasonNone) in the lpdwRebootReasons output parameter when
calling the RmGetList API to detect a cygrunsrv service.

Further details (regarding Inno Setup and this problem):
https://groups.google.com/d/msg/innosetup/9dAT3wB9RTQ/99Py-ZgLCgAJ

Any ideas why Restart Manager doesn't work for cygrunsrv services?

Thanks!

Bill

____________________

[1] https://docs.microsoft.com/en-us/windows/win32/rstmgr/about-restart-manager

[2] https://docs.microsoft.com/en-us/windows/win32/api/restartmanager/nf-restartmanager-rmgetlist

[3] https://docs.microsoft.com/en-us/windows/win32/api/restartmanager/ne-restartmanager-rm_reboot_reason

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Windows Restart Manager and cygrunsrv services
  2020-01-23 17:44 Windows Restart Manager and cygrunsrv services Bill Stewart
@ 2020-01-27 16:20 ` Bill Stewart
  2020-01-27 22:24   ` Bill Stewart
  0 siblings, 1 reply; 3+ messages in thread
From: Bill Stewart @ 2020-01-27 16:20 UTC (permalink / raw)
  To: cygwin

On Thu, Jan 23, 2020 at 10:44 AM Bill Stewart wrote:

> However it seems that when running a service using cygrunsrv, the
> Restart Manager RmGetList API[2] returns RmRebootReasonSessionMismatch
> (2) for the lpdwRebootReasons output parameter.
>
> This parameter return value is one of the RM_REBOOT_REASON enumeration
> values[3].
>
> The description for the RmRebootReasonSessionMismatch value on MSDN is
> as follows: "One or more processes are running in another Terminal
> Services session."
>
> I ran into this building an Inno Setup installer. I reproduced on
> Windows 10 x64 and Windows Server 2008 R2 x64.
>
> The error description is interesting, because in neither repro case
> were there other users logged on using TS sessions. (I'm not sure if
> that error description is completely accurate in describing all cases
> where that value gets returned, though...)
>
> Unexpected behavior: Restart Manager returns 2
> (RmRebootReasonSessionMismatch) in the lpdwRebootReasons output
> parameter when calling the RmGetList API to detect a cygrunsrv
> service.
>
> Expected behavior: Restart Manager should return 0
> (RmRebootReasonNone) in the lpdwRebootReasons output parameter when
> calling the RmGetList API to detect a cygrunsrv service.
>
> Further details (regarding Inno Setup and this problem):
> https://groups.google.com/d/msg/innosetup/9dAT3wB9RTQ/99Py-ZgLCgAJ
>
> Any ideas why Restart Manager doesn't work for cygrunsrv services?
>
> Thanks!
>
> Bill
>
> ____________________
>
> [1] https://docs.microsoft.com/en-us/windows/win32/rstmgr/about-restart-manager
>
> [2] https://docs.microsoft.com/en-us/windows/win32/api/restartmanager/nf-restartmanager-rmgetlist
>
> [3] https://docs.microsoft.com/en-us/windows/win32/api/restartmanager/ne-restartmanager-rm_reboot_reason

Question also posted on StackOverflow:

https://stackoverflow.com/questions/59902201/

Any insights appreciated.

Thanks!

Bill

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Windows Restart Manager and cygrunsrv services
  2020-01-27 16:20 ` Bill Stewart
@ 2020-01-27 22:24   ` Bill Stewart
  0 siblings, 0 replies; 3+ messages in thread
From: Bill Stewart @ 2020-01-27 22:24 UTC (permalink / raw)
  To: cygwin

On Mon, Jan 27, 2020 at 9:19 AM Bill Stewart wrote:

> > Any ideas why Restart Manager doesn't work for cygrunsrv services?
> ...
> Question also posted on StackOverflow:
>
> https://stackoverflow.com/questions/59902201/
>
> Any insights appreciated.

According to my investigation and understanding as of this writing,
the behavior appears to be as follows:

1. Restart Manager sees the cygrunsrv.exe executable correctly as a
service and as restartable. This is good.

2. However, any executable spawned by cygrunsrv.exe as a service
(e.g., sshd.exe), is seen as NOT restartable for some reason. This is
not so good, and prevents the service from being restarted
automatically by Restart Manager.

I don't know the explanation for this behavior. It seems unintuitive
and is confusing, at the least.

Just a guess: Perhaps this behavior would be resolved if Cygwin
executables used RegisterApplicationRestart[1] ?

In any case, I have an imperfect workaround, but it would be good if
this workaround wasn't necessary.

Regards,

Bill

__________

[1] https://docs.microsoft.com/en-us/windows/win32/recovery/registering-for-application-restart

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-27 22:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-23 17:44 Windows Restart Manager and cygrunsrv services Bill Stewart
2020-01-27 16:20 ` Bill Stewart
2020-01-27 22:24   ` Bill Stewart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).