mirror of
https://github.com/golang/sys.git
synced 2026-02-08 11:46:04 +03:00
windows/svc: do not close service handle
The documentation [1] says "The service status handle does not have to be closed." That makes it seem like it's optional. But actually, closing it raises a user exception, because it's not a legitimate handle to close. This commit also adds the right go build comments with a `go fmt` pass. [1] https://docs.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-registerservicectrlhandlerexa Change-Id: Ibf67c0e8d94c87068720472009b24cecdfda6519 Reviewed-on: https://go-review.googlesource.com/c/sys/+/357250 Trust: Jason A. Donenfeld <Jason@zx2c4.com> Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package svc
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
// Package svc provides everything required to build Windows service.
|
||||
@@ -201,7 +202,6 @@ func serviceMain(argc uint32, argv **uint16) uintptr {
|
||||
theService.h = handle
|
||||
defer func() {
|
||||
theService.h = 0
|
||||
windows.CloseHandle(handle)
|
||||
}()
|
||||
var args16 []*uint16
|
||||
hdr := (*unsafeheader.Slice)(unsafe.Pointer(&args16))
|
||||
|
||||
Reference in New Issue
Block a user