From f330392ccf6f9fc4267d0a4ca94ef72f5c713609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Sat, 30 Nov 2019 10:57:29 +0100 Subject: [PATCH] narrow match with UID, print persistent matching processes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- nix/mobile/ios/install-pods-and-status-go.sh | 2 +- scripts/wait-for.sh | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/nix/mobile/ios/install-pods-and-status-go.sh b/nix/mobile/ios/install-pods-and-status-go.sh index 4fac344d44..d301e17326 100755 --- a/nix/mobile/ios/install-pods-and-status-go.sh +++ b/nix/mobile/ios/install-pods-and-status-go.sh @@ -24,7 +24,7 @@ else fi if [ "$(uname)" == 'Darwin' ]; then # 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 fi fi diff --git a/scripts/wait-for.sh b/scripts/wait-for.sh index d43700a39f..6c83f06275 100755 --- a/scripts/wait-for.sh +++ b/scripts/wait-for.sh @@ -4,25 +4,30 @@ set -e TIMEOUT=${1} shift -PGREP_OPTS=${@} +PGREP_FILTER=${@} SLEEP_SEC=5 STEPS=$((TIMEOUT / SLEEP_SEC)) +# use UID to restrict search +PGREP_OPTS="-U ${UID} -f" if [[ -z ${PGREP_OPTS} ]]; then echo "No pgrep options name specified!" >&2 exit 1 fi -echo "Checking for process: '${PGREP_OPTS}'" +echo "Checking for process: '${PGREP_FILTER}'" 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 sleep ${SLEEP_SEC} else - echo "Process '${PGREP_OPTS}' gone." >&2 + echo "Process '${PGREP_FILTER}' gone." >&2 exit 0 fi done 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