diff --git a/.vscode/settings.json b/.vscode/settings.json index ebb2f31ee3a..9e68654eef9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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" } diff --git a/yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh b/yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh index 8eec17e179f..f03ae0e1abb 100755 --- a/yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh +++ b/yarn-project/end-to-end/scripts/anvil_kill_wrapper.sh @@ -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 $@ & @@ -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 \ No newline at end of file +while check_process_alive $PARENT_PID; do + sleep 1 +done