From ed752295db8857b3a7f36c3f57e38509cadff471 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 3 Dec 2020 01:11:27 +0100 Subject: [PATCH] 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 TryBot-Result: Go Bot Reviewed-by: Alex Brainman Trust: Alex Brainman Trust: Jason A. Donenfeld --- windows/svc/mgr/service.go | 8 +++++--- windows/svc/service.go | 12 +++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/windows/svc/mgr/service.go b/windows/svc/mgr/service.go index ded1c7a4..aee2d3d2 100644 --- a/windows/svc/mgr/service.go +++ b/windows/svc/mgr/service.go @@ -68,8 +68,10 @@ func (s *Service) Query() (svc.Status, error) { return svc.Status{}, err } return svc.Status{ - State: svc.State(t.CurrentState), - Accepts: svc.Accepted(t.ControlsAccepted), - ProcessId: t.ProcessId, + State: svc.State(t.CurrentState), + Accepts: svc.Accepted(t.ControlsAccepted), + ProcessId: t.ProcessId, + Win32ExitCode: t.Win32ExitCode, + ServiceSpecificExitCode: t.ServiceSpecificExitCode, }, nil } diff --git a/windows/svc/service.go b/windows/svc/service.go index f7f4ff5b..37485286 100644 --- a/windows/svc/service.go +++ b/windows/svc/service.go @@ -71,11 +71,13 @@ const ( // Status combines State and Accepted commands to fully describe running service. type Status struct { - State State - Accepts Accepted - CheckPoint uint32 // used to report progress during a lengthy operation - 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 + State State + Accepts Accepted + CheckPoint uint32 // used to report progress during a lengthy operation + 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 + 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.