Skip to content

Commit

Permalink
Revert "Merge pull request #2962 from ActiveState/mitchell/dx-2373"
Browse files Browse the repository at this point in the history
This reverts commit 08f1013, reversing
changes made to fc6d0d1.
  • Loading branch information
mitchell-as committed Feb 6, 2024
1 parent f136b9f commit a4235d2
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions internal/osutils/osutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"path/filepath"
"runtime"
"strings"
"sync"

"github.com/shirou/gopsutil/v3/process"

Expand Down Expand Up @@ -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
}

0 comments on commit a4235d2

Please sign in to comment.