Skip to content

Commit

Permalink
chore: anvil kill wrapper now supports mac (#6520)
Browse files Browse the repository at this point in the history
Also remove errant workspace settings. Should we remove it from source
control?
  • Loading branch information
just-mitch authored May 20, 2024
1 parent bf441da commit 2a5d975
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
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

0 comments on commit 2a5d975

Please sign in to comment.