Skip to content

Commit ff2c564

Browse files
authored
feat(foundryup): check for running processes (#9680)
1 parent 5b4a105 commit ff2c564

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

foundryup/foundryup

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ main() {
6363
fi
6464
fi
6565

66+
check_bins_in_use
67+
6668
# Installs foundry from a local repository if --path parameter is provided
6769
if [[ -n "$FOUNDRYUP_LOCAL_REPO" ]]; then
6870
need_cmd cargo
@@ -292,6 +294,9 @@ use() {
292294
[ -z "$FOUNDRYUP_VERSION" ] && err "no version provided"
293295
FOUNDRY_VERSION_DIR="$FOUNDRY_VERSIONS_DIR/$FOUNDRYUP_VERSION"
294296
if [ -d "$FOUNDRY_VERSION_DIR" ]; then
297+
298+
check_bins_in_use
299+
295300
for bin in "${BINS[@]}"; do
296301
bin_path="$FOUNDRY_BIN_DIR/$bin"
297302
cp $FOUNDRY_VERSION_DIR/$bin $bin_path
@@ -346,6 +351,18 @@ check_cmd() {
346351
command -v "$1" &>/dev/null
347352
}
348353

354+
check_bins_in_use() {
355+
if check_cmd pgrep; then
356+
for bin in "${BINS[@]}"; do
357+
if pgrep -x "$bin" >/dev/null; then
358+
err "Error: '$bin' is currently running. Please stop the process and try again."
359+
fi
360+
done
361+
else
362+
warn "Make sure no foundry process is running during the install process!"
363+
fi
364+
}
365+
349366
# Run a command that should never fail. If the command fails execution
350367
# will immediately terminate with an error showing the failing command.
351368
ensure() {

0 commit comments

Comments
 (0)