summaryrefslogtreecommitdiff
path: root/local/bin/killradio
blob: 46e7d6e614709242780c5fe2d2c23c837e4b284f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/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}")