فهرست منبع

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>
Jason A. Donenfeld 6 سال پیش
والد
کامیت
b397fe3ad8
1فایلهای تغییر یافته به همراه3 افزوده شده و 3 حذف شده
  1. 3 3
      windows/svc/mgr/mgr.go

+ 3 - 3
windows/svc/mgr/mgr.go

@@ -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
 		}
 	}