#!/usr/bin/env python3
import subprocess
import sys
import signal

try:
    # Find PID(s) of running 'radio' process (matching name)
    out = subprocess.check_output(["pgrep", "-f", "radio"])
    pids = [int(pid) for pid in out.decode().strip().split()]
except subprocess.CalledProcessError:
    print("No running 'radio' process found.")
    sys.exit(1)

for pid in pids:
    try:
        # Send SIGKILL (kill -9) to each found pid
        subprocess.run(["kill", "-9", str(pid)])
        print(f"Killed PID {pid}")
    except Exception as e:
        print(f"Failed to kill PID {pid}: {e}")
