#!/bin/sh ASPID=$(pidof airspy_adsb) if [ -z "${ASPID}" ]; then exit 0 fi # Connect for up to 3 seconds and expect to receive at least 5 lines. You can # update these numbers to different thresholds. if ! timeout 3 sh -c "nc localhost 33333 | head -5" > /dev/null; then ASPID=$(pidof airspy_adsb) if grep -qE 'VmPeak.*[0-9]{7}' /proc/${ASPID}/status; then # At the time it was I think leaking memory address space (I # *think* not that much actual memory?) and at some point # get stuck when hitting the Pi's limits so a restart would be # enough to revive. kill -9 ${ASPID} else # If the memory state looks fine though, just reboot. /sbin/shutdown -r +2 fi fi