From 8fc68db0c09fdf7e31473957cdd9e4c7c0585843 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 8 Oct 2022 15:05:59 +0200 Subject: [PATCH] cmd/containerd: replace deprecated windows.IsAnInteractiveSession() The `IsAnInteractiveSession` was deprecated, and `IsWindowsService` is marked as the recommended replacement. For details, see https://github.com/golang/sys/commit/280f808b4a5303f80a30dd9dc62f9a042d992ad0 > CL 244958 includes isWindowsService function that determines if a > process is running as a service. The code of the function is based on > public .Net implementation. > > IsAnInteractiveSession function implements similar functionality, but > is based on an old Stackoverflow post., which is not as authoritative > as code written by Microsoft for their official product. > > This change copies CL 244958 isWindowsService function into svc package > and makes it public. The intention is that future users will prefer > IsWindowsService to IsAnInteractiveSession. Signed-off-by: Sebastiaan van Stijn --- cmd/containerd/command/service_windows.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/containerd/command/service_windows.go b/cmd/containerd/command/service_windows.go index 2c682b4e8..e36bac5ba 100644 --- a/cmd/containerd/command/service_windows.go +++ b/cmd/containerd/command/service_windows.go @@ -307,16 +307,17 @@ func launchService(s *server.Server, done chan struct{}) error { done: done, } - interactive, err := svc.IsAnInteractiveSession() // nolint:staticcheck + // Check if we're running as a Windows service or interactively. + isService, err := svc.IsWindowsService() if err != nil { return err } go func() { - if interactive { - err = debug.Run(serviceNameFlag, h) - } else { + if isService { err = svc.Run(serviceNameFlag, h) + } else { + err = debug.Run(serviceNameFlag, h) } h.fromsvc <- err }()