Skip to content

Commit

Permalink
Test suite: Don't use "pgrep -u" when LOGNAME and USER are not set
Browse files Browse the repository at this point in the history
Thanks for reporting this on IRC, luca!
  • Loading branch information
alexbarton committed Apr 13, 2024
1 parent b362b5a commit a33d157
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/testsuite/getpid.sh
Expand Up @@ -23,7 +23,13 @@ if [ -x /usr/bin/pgrep ]; then
*)
PGREP_FLAGS=""
esac
exec /usr/bin/pgrep $PGREP_FLAGS -n -u "${LOGNAME:-$USER}" "$1"
if [ -n "$LOGNAME" ] || [ -n "$USER" ]; then
# Try to narrow the search down to the current user ...
exec /usr/bin/pgrep $PGREP_FLAGS -n -u "${LOGNAME:-$USER}" "$1"
else
# ... but neither LOGNAME nor USER were set!
exec /usr/bin/pgrep $PGREP_FLAGS -n "$1"
fi
fi

# pidof(1) could be a good alternative on elder Linux systems
Expand Down

0 comments on commit a33d157

Please sign in to comment.