Skip to content

Commit

Permalink
Rescue Errno::EPERM
Browse files Browse the repository at this point in the history
The api we call to get task info will raise this if you don't have
permission (eg trying to get info about another user's processes
when not root). By returning nil we'll fall back to the base case
of shelling out to `ps` (which doesn't have this issue because `ps` is
installed setuid & with the correct entitlements for this)
  • Loading branch information
fcheung committed Aug 27, 2020
1 parent 491b186 commit 42af938
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/get_process_mem.rb
Expand Up @@ -120,5 +120,7 @@ def ps_memory

def darwin_memory
Darwin.resident_size(pid)
rescue Errno::EPERM
nil
end
end

0 comments on commit 42af938

Please sign in to comment.