beads/internal/storage/dbproxy/proxy/process_executable_windows.go
matt wilkie 7f04e6fdcc
fix(lint): check deferred windows.CloseHandle returns (errcheck) (#5088)
Main went red at e2dd121f4: the Build Artifacts / PR Lint windows lint
pass flags three bare 'defer windows.CloseHandle(...)' calls in
internal/procid/procid_windows.go and
internal/storage/dbproxy/proxy/process_executable_windows.go
(introduced with #5013). Switched to the established convention used
everywhere else in the tree: defer func() { _ = windows.CloseHandle(...) }().

Verified: GOOS=windows go build of both packages and golangci-lint
clean.

Agent-Signature: claude-fable-5-high on behalf of matt wilkie
2026-07-26 14:47:37 -07:00

29 lines
730 B
Go

//go:build windows
package proxy
import (
"errors"
"path/filepath"
"syscall"
"golang.org/x/sys/windows"
)
func processExecutableBasename(pid int) (basename string, gone bool, err error) {
process, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid))
if err != nil {
if errors.Is(err, windows.ERROR_INVALID_PARAMETER) {
return "", true, nil
}
return "", false, err
}
defer func() { _ = windows.CloseHandle(process) }()
buffer := make([]uint16, 32768)
size := uint32(len(buffer))
if err := windows.QueryFullProcessImageName(process, 0, &buffer[0], &size); err != nil {
return "", false, err
}
return filepath.Base(syscall.UTF16ToString(buffer[:size])), false, nil
}