windows/svc/mgr: report exit status when querying services

One thing the newer notification API does not do is automatically
provide the service exit code in its notifier response. It requires
querying manually. Unfortunately, we weren't propagating this
information up from the lower level struct, so this commit copys that
information over.

Change-Id: I70c683007ce34ffab6196329acefc8443f921ebe
Reviewed-on: https://go-review.googlesource.com/c/sys/+/274577
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld
2020-12-04 22:54:14 +00:00
parent c9906e3070
commit ed752295db
2 changed files with 12 additions and 8 deletions
+5 -3
View File
@@ -68,8 +68,10 @@ func (s *Service) Query() (svc.Status, error) {
return svc.Status{}, err return svc.Status{}, err
} }
return svc.Status{ return svc.Status{
State: svc.State(t.CurrentState), State: svc.State(t.CurrentState),
Accepts: svc.Accepted(t.ControlsAccepted), Accepts: svc.Accepted(t.ControlsAccepted),
ProcessId: t.ProcessId, ProcessId: t.ProcessId,
Win32ExitCode: t.Win32ExitCode,
ServiceSpecificExitCode: t.ServiceSpecificExitCode,
}, nil }, nil
} }
+7 -5
View File
@@ -71,11 +71,13 @@ const (
// Status combines State and Accepted commands to fully describe running service. // Status combines State and Accepted commands to fully describe running service.
type Status struct { type Status struct {
State State State State
Accepts Accepted Accepts Accepted
CheckPoint uint32 // used to report progress during a lengthy operation CheckPoint uint32 // used to report progress during a lengthy operation
WaitHint uint32 // estimated time required for a pending operation, in milliseconds WaitHint uint32 // estimated time required for a pending operation, in milliseconds
ProcessId uint32 // if the service is running, the process identifier of it, and otherwise zero ProcessId uint32 // if the service is running, the process identifier of it, and otherwise zero
Win32ExitCode uint32 // set if the service has exited with a win32 exit code
ServiceSpecificExitCode uint32 // set if the service has exited with a service-specific exit code
} }
// ChangeRequest is sent to the service Handler to request service status change. // ChangeRequest is sent to the service Handler to request service status change.