narrow match with UID, print persistent matching processes

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-11-30 10:57:29 +01:00
parent 13a619502c
commit f330392ccf
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
2 changed files with 10 additions and 5 deletions

View File

@ -24,7 +24,7 @@ else
fi fi
if [ "$(uname)" == 'Darwin' ]; then if [ "$(uname)" == 'Darwin' ]; then
# CocoaPods are trash and can't handle other pod instances running at the same time # CocoaPods are trash and can't handle other pod instances running at the same time
$STATUS_REACT_HOME/scripts/wait-for.sh 240 -f 'pod' $STATUS_REACT_HOME/scripts/wait-for.sh 240 'pod install'
pushd $STATUS_REACT_HOME/ios && pod install; popd pushd $STATUS_REACT_HOME/ios && pod install; popd
fi fi
fi fi

View File

@ -4,25 +4,30 @@ set -e
TIMEOUT=${1} TIMEOUT=${1}
shift shift
PGREP_OPTS=${@} PGREP_FILTER=${@}
SLEEP_SEC=5 SLEEP_SEC=5
STEPS=$((TIMEOUT / SLEEP_SEC)) STEPS=$((TIMEOUT / SLEEP_SEC))
# use UID to restrict search
PGREP_OPTS="-U ${UID} -f"
if [[ -z ${PGREP_OPTS} ]]; then if [[ -z ${PGREP_OPTS} ]]; then
echo "No pgrep options name specified!" >&2 echo "No pgrep options name specified!" >&2
exit 1 exit 1
fi fi
echo "Checking for process: '${PGREP_OPTS}'" echo "Checking for process: '${PGREP_FILTER}'"
for ((i = 0; i < ${STEPS}; i += 1)); do for ((i = 0; i < ${STEPS}; i += 1)); do
if pgrep ${PGREP_OPTS} > /dev/null; then if pgrep ${PGREP_OPTS} "${PGREP_FILTER}" > /dev/null; then
echo "Process found. Sleeping ${SLEEP_SEC}..." >&2 echo "Process found. Sleeping ${SLEEP_SEC}..." >&2
sleep ${SLEEP_SEC} sleep ${SLEEP_SEC}
else else
echo "Process '${PGREP_OPTS}' gone." >&2 echo "Process '${PGREP_FILTER}' gone." >&2
exit 0 exit 0
fi fi
done done
echo "Timeout reached! (${TIMEOUT}s) Process still up: ${PGREP_OPTS}" >&2 echo "Timeout reached! (${TIMEOUT}s) Process still up: ${PGREP_OPTS}" >&2
echo "Following processes matched:"
# show what is still up
ps u $(pgrep -l ${PGREP_OPTS} "${PGREP_FILTER}" | cut -d' ' -f1 | xargs -I{} echo -n "-p {} ")
exit 1 exit 1