Skip to content

Commit

Permalink
Merge pull request #236 from patcable/jvm-jmaps-fix
Browse files Browse the repository at this point in the history
Get the process' running GID in addition to UID
  • Loading branch information
brendangregg authored Jul 29, 2020
2 parents 1a0dc69 + 1a9c283 commit a258e78
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions jmaps
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ for pid in $(pgrep -x java); do
(( debug )) && echo $cmd

user=$(ps ho user -p $pid)
group=$(ps ho group -p $pid)
if [[ "$user" != root ]]; then
if [[ "$user" == [0-9]* ]]; then
# UID only, run sudo with #UID:
cmd="sudo -u '#'$user sh -c '$cmd'"
# UID only, likely GID too, run sudo with #UID:
cmd="sudo -u '#'$user -g '#'$group sh -c '$cmd'"
else
cmd="sudo -u $user sh -c '$cmd'"
cmd="sudo -u $user -g $group sh -c '$cmd'"
fi
fi

Expand Down

0 comments on commit a258e78

Please sign in to comment.