Skip to content

Commit a4b8c5b

Browse files
committed
Service.Control: set State and Accepted when returning certain errors
1 parent 39c2d6a commit a4b8c5b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

windows/svc/mgr/service.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ func (s *Service) Start(args ...string) error {
4949
func (s *Service) Control(c svc.Cmd) (svc.Status, error) {
5050
var t windows.SERVICE_STATUS
5151
err := windows.ControlService(s.Handle, uint32(c), &t)
52-
if err != nil {
52+
if err != nil &&
53+
err != windows.ERROR_INVALID_SERVICE_CONTROL &&
54+
err != windows.ERROR_SERVICE_CANNOT_ACCEPT_CTRL &&
55+
err != windows.ERROR_SERVICE_NOT_ACTIVE {
5356
return svc.Status{}, err
5457
}
5558
return svc.Status{
5659
State: svc.State(t.CurrentState),
5760
Accepts: svc.Accepted(t.ControlsAccepted),
58-
}, nil
61+
}, err
5962
}
6063

6164
// Query returns current status of service s.

0 commit comments

Comments
 (0)