Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: anvil kill wrapper now supports mac #6520

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,5 @@
"**/l1-contracts/lib/**": true,
"**/barretenberg/cpp/build*/**": true
},
"cmake.sourceDirectory": "/mnt/user-data/adam/aztec-packages/barretenberg/acir_tests/headless-test/node_modules/bare-fs"
"cmake.sourceDirectory": "${workspaceFolder}/barretenberg/cpp"
}
42 changes: 37 additions & 5 deletions yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
#!/bin/bash

# Find the parent of this script.
PARENT_PID=$(awk '{print $4}' /proc/$$/stat)
# Function to get the PPID in macOS
get_ppid_macos() {
ps -j $$ | awk 'NR==2 {print $3}'
}

# Function to get the PPID in Linux
get_ppid_linux() {
awk '{print $4}' /proc/$$/stat
}

# Function to check if a process is alive in macOS
is_process_alive_macos() {
ps -p $1 > /dev/null 2>&1
}

# Function to check if a process is alive in Linux
is_process_alive_linux() {
[ -d /proc/$1 ]
}


# Determine the operating system and call the appropriate function
if [[ "$OSTYPE" == "darwin"* ]]; then
PARENT_PID=$(get_ppid_macos)
check_process_alive() { is_process_alive_macos $1; }
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
PARENT_PID=$(get_ppid_linux)
check_process_alive() { is_process_alive_linux $1; }
else
echo "Unsupported OS"
exit 1
fi

# echo "Parent PID: $PARENT_PID"

# Start anvil in the background.
anvil $@ &
Expand All @@ -14,6 +46,6 @@ cleanup() {
trap cleanup EXIT

# Continuously check if the parent process is still alive.
while [ -d /proc/$PARENT_PID ]; do
sleep 1
done
while check_process_alive $PARENT_PID; do
sleep 1
done
Loading