Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: EMFILE error on macOS Catalina #118

Merged
merged 3 commits into from
Aug 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions goprocess/gp.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type P struct {

// FindAll returns all the Go processes currently running on this host.
func FindAll() []P {
const concurrencyProcesses = 10 // limit the maximum number of concurrent reading process tasks
pss, err := ps.Processes()
if err != nil {
return nil
Expand All @@ -35,10 +36,13 @@ func FindAll() []P {
var wg sync.WaitGroup
wg.Add(len(pss))
found := make(chan P)
limitCh := make(chan struct{}, concurrencyProcesses)

for _, pr := range pss {
limitCh <- struct{}{}
pr := pr
go func() {
defer func() { <-limitCh }()
defer wg.Done()

path, version, agent, ok, err := isGo(pr)
Expand Down