mirror of
https://github.com/golang/sys.git
synced 2026-02-08 03:36:03 +03:00
windows/svc: use CloseServiceHandle for service handles
From MSDN on CreateServiceW: The returned handle is only valid for the process that called CreateService. It can be closed by calling the CloseServiceHandle function. This isn't an actual kernel object to be closed with CloseHandle. Change-Id: Iee225a666576d57a6c4864abef20206d54cbbce2 Reviewed-on: https://go-review.googlesource.com/c/sys/+/198298 Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -137,7 +137,7 @@ func (m *Mgr) CreateService(name, exepath string, c Config, args ...string) (*Se
|
||||
err = updateSidType(h, c.SidType)
|
||||
if err != nil {
|
||||
windows.DeleteService(h)
|
||||
windows.CloseHandle(h)
|
||||
windows.CloseServiceHandle(h)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func (m *Mgr) CreateService(name, exepath string, c Config, args ...string) (*Se
|
||||
err = updateDescription(h, c.Description)
|
||||
if err != nil {
|
||||
windows.DeleteService(h)
|
||||
windows.CloseHandle(h)
|
||||
windows.CloseServiceHandle(h)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ func (m *Mgr) CreateService(name, exepath string, c Config, args ...string) (*Se
|
||||
err = updateStartUp(h, c.DelayedAutoStart)
|
||||
if err != nil {
|
||||
windows.DeleteService(h)
|
||||
windows.CloseHandle(h)
|
||||
windows.CloseServiceHandle(h)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user