Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

init: crash recovery instead of kernel panic

Don't exec ac-native as PID 1 — run it as a child process in a loop.
If ac-native crashes (segfault, abort, etc.):
- Paint solid red screen to framebuffer as visual crash indicator
- Write crash.json with exit code and timestamp
- Auto-restart after 3s (up to 5 times)
- Clean exit (code 0) triggers poweroff

Previously, ac-native WAS init (PID 1), so any crash caused a kernel
panic (blinking caps lock, frozen screen, no recovery).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+54 -2
+54 -2
fedac/native/initramfs/init
··· 59 59 echo performance > "$g" 2>/dev/null 60 60 done 61 61 62 - ilog "exec-ac-native" 63 - exec /ac-native /piece.mjs 62 + ilog "starting ac-native" 63 + 64 + # Run ac-native as a child (NOT exec) so init survives crashes. 65 + # If ac-native segfaults, we catch it, paint a red crash screen, 66 + # log the error, and restart after a brief pause. 67 + CRASH_COUNT=0 68 + MAX_CRASHES=5 69 + 70 + while true; do 71 + /ac-native /piece.mjs 72 + EXIT_CODE=$? 73 + CRASH_COUNT=$((CRASH_COUNT + 1)) 74 + 75 + ilog "ac-native exited with code ${EXIT_CODE} (crash #${CRASH_COUNT})" 76 + 77 + # Clean exit (code 0) means intentional shutdown 78 + if [ "${EXIT_CODE}" -eq 0 ]; then 79 + ilog "clean exit — powering off" 80 + poweroff -f 2>/dev/null 81 + sleep 999 82 + fi 83 + 84 + # Paint red crash screen to framebuffer 85 + FB="/dev/fb0" 86 + if [ -c "${FB}" ]; then 87 + # Get framebuffer dimensions 88 + FB_W=$(cat /sys/class/graphics/fb0/virtual_size 2>/dev/null | cut -d, -f1) 89 + FB_H=$(cat /sys/class/graphics/fb0/virtual_size 2>/dev/null | cut -d, -f2) 90 + FB_W=${FB_W:-1920} 91 + FB_H=${FB_H:-1080} 92 + # Fill with dark red (BGRA: 00 00 80 FF) 93 + TOTAL=$((FB_W * FB_H * 4)) 94 + dd if=/dev/zero bs=4096 count=$((TOTAL / 4096 + 1)) 2>/dev/null | \ 95 + tr '\000' '\200' > "${FB}" 2>/dev/null 96 + # Override: write solid red pixels (0x00 0x00 0xCC 0xFF pattern) 97 + { 98 + PIXEL=$(printf '\x00\x00\xcc\xff') 99 + yes "${PIXEL}" | head -c "${TOTAL}" 100 + } > "${FB}" 2>/dev/null 101 + ilog "crash screen displayed on ${FB} (${FB_W}x${FB_H})" 102 + fi 103 + 104 + # Save crash info to USB (ac-native writes log to USB on next boot) 105 + echo "{\"exit\":${EXIT_CODE},\"crash\":${CRASH_COUNT},\"ts\":\"$(date -u +%Y-%m-%dT%H:%M:%S 2>/dev/null || echo unknown)\"}" > /tmp/crash.json 106 + 107 + # Too many crashes — give up 108 + if [ "${CRASH_COUNT}" -ge "${MAX_CRASHES}" ]; then 109 + ilog "max crashes (${MAX_CRASHES}) reached — halting" 110 + sleep 999999 111 + fi 112 + 113 + ilog "restarting in 3s..." 114 + sleep 3 115 + done