Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Commit

Permalink
fix: Process name matching switched to exact match
Browse files Browse the repository at this point in the history
  • Loading branch information
lholota committed May 27, 2020
1 parent 7ca851c commit 434c12a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public GenericContainerEx<SELF> withRelativeFileSystemBind(String relativePath,
}

public Integer getProcessUid(String processName) throws IOException, InterruptedException, ProcessNotFoundException {
ExecResult result = executeShellCommand("stat -c '%u' /proc/$(ps axf | grep '"+ processName +"$' | grep -v grep | awk -v def=\"not-found\" '{ print $1 } END { if(NR==0) {print def} }')");
ExecResult result = executeShellCommand("stat -c '%u' /proc/$(ps axf | pgrep -f '^"+ processName +"$' | awk -v def=\"not-found\" '{ print $1 } END { if(NR==0) {print def} }')");

if(result.getExitCode() != 0) {
throw new ProcessNotFoundException(processName);
Expand All @@ -51,7 +51,7 @@ public Integer getProcessUid(String processName) throws IOException, Interrupted
}

public Integer getProcessGid(String processName) throws IOException, InterruptedException, ProcessNotFoundException {
ExecResult result = executeShellCommand("stat -c '%g' /proc/$(ps axf | grep '"+ processName +"$' | grep -v grep | awk -v def=\"not-found\" '{ print $1 } END { if(NR==0) {print def} }')");
ExecResult result = executeShellCommand("stat -c '%g' /proc/$(ps axf | pgrep -f '^"+ processName +"$' | awk -v def=\"not-found\" '{ print $1 } END { if(NR==0) {print def} }')");

if(result.getExitCode() != 0) {
throw new ProcessNotFoundException(processName);
Expand Down

0 comments on commit 434c12a

Please sign in to comment.