#!/bin/bash
# /etc/rc.d/crashd — the system-wide crash reporter (#59 Phase 3).
#
# crashd blocks in SYS_crashwait and, as ANY process dies from a fault-class
# signal, prints a symbolized report to serial and — when a compositor is up —
# opens a native Fasadas window (/Applications/CrashReporter.aop). It is started
# first (alphabetically before network/sshd) so a crash during the rest of boot
# is still reported. Runs in the background; a real supervisor with a crash-loop
# guard is a later refinement (plan section 8.2).
case "$1" in
    start)
        if [ ! -x /bin/crashd ]; then
            echo "rc: crashd: /bin/crashd missing or not executable" >&2
            exit 1
        fi
        /bin/crashd &
        ;;
    stop)
        killall crashd 2>/dev/null
        ;;
    *)
        echo "usage: $0 start|stop" >&2; exit 1 ;;
esac
exit 0
