#!/bin/bash

# sh ./stop_leaks.sh  /Users/cl/Downloads/zreport
if [ "$#" -ne 1 ]; then
    echo "Usage: \$0 <outputPath>"
    exit 1
fi

outputPath=$1
echo "Attempting to read PID from ${outputPath}/pid.txt"
pid=$(cat ${outputPath}/pid.txt 2>/dev/null)
echo "Read PID: $pid"

if [ -z "$pid" ]; then
    echo "No PID found in file"
    exit 1
fi

if kill -2 $pid; then
    echo "Signal sent successfully to PID $pid"
else
    echo "Failed to send signal to PID $pid"
fi

sleep 3
