From a4235d2d9619fd8e0f66e53982cb59c0eb2ea2c9 Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 6 Feb 2024 13:27:22 -0500 Subject: [PATCH] Revert "Merge pull request #2962 from ActiveState/mitchell/dx-2373" This reverts commit 08f1013495150b36da3a3f4de1705b0b56dcaf8f, reversing changes made to fc6d0d16e9a9b5af50b53a2d6b719d5befa4d016. --- internal/osutils/osutils.go | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/internal/osutils/osutils.go b/internal/osutils/osutils.go index 6a9e10ef32..5c3e65782a 100644 --- a/internal/osutils/osutils.go +++ b/internal/osutils/osutils.go @@ -8,7 +8,6 @@ import ( "path/filepath" "runtime" "strings" - "sync" "github.com/shirou/gopsutil/v3/process" @@ -139,30 +138,21 @@ func GetProcessesInUse(dir string) map[string]int32 { return inUse } - var wg sync.WaitGroup - var mutex sync.Mutex if runtime.GOOS != "linux" { dir = strings.ToLower(dir) // Windows and macOS filesystems are case-insensitive } for _, p := range procs { - wg.Add(1) - go func(p *process.Process) { - defer wg.Done() - exe, err := p.Exe() - if err != nil { - return // probably a permission error; ignore - } - exeToCompare := exe - if runtime.GOOS != "linux" { - exeToCompare = strings.ToLower(exeToCompare) // Windows and macOS filesystems are case-insensitive - } - if strings.Contains(exeToCompare, dir) { - mutex.Lock() - inUse[exe] = p.Pid - mutex.Unlock() - } - }(p) + exe, err := p.Exe() + if err != nil { + continue // probably a permission error; ignore + } + exeToCompare := exe + if runtime.GOOS != "linux" { + exeToCompare = strings.ToLower(exeToCompare) // Windows and macOS filesystems are case-insensitive + } + if strings.Contains(exeToCompare, dir) { + inUse[exe] = p.Pid + } } - wg.Wait() return inUse }