Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

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

fix: proper poweroff/reboot — exit codes 0/2, no SIGTERM to init

poweroff: _exit(0) → init uses sysrq 'o'
reboot: _exit(2) → init uses sysrq 'b'
No more getpid()==1 checks or SIGTERM/SIGUSR2 to PID 1.

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

+16 -21
+11 -4
fedac/native/initramfs/init
··· 113 113 /ac-native /piece.mjs 114 114 EXIT_CODE=$? 115 115 116 - # Clean exit (0) = shutdown requested 116 + # Exit code 0 = power off, exit code 2 = reboot 117 117 if [ "$EXIT_CODE" = "0" ]; then 118 118 sync 119 119 echo "[ac-init] Clean exit — powering off..." 120 - # Sysrq power off (most reliable under initramfs) 121 120 echo o > /proc/sysrq-trigger 2>/dev/null 122 121 sleep 2 123 - # Busybox poweroff 124 122 poweroff -f 2>/dev/null 125 123 busybox poweroff -f 2>/dev/null 126 - # If nothing worked, halt (do NOT reboot) 124 + sleep 30 125 + break 126 + fi 127 + if [ "$EXIT_CODE" = "2" ]; then 128 + sync 129 + echo "[ac-init] Reboot requested..." 130 + echo b > /proc/sysrq-trigger 2>/dev/null 131 + sleep 2 132 + reboot -f 2>/dev/null 133 + busybox reboot -f 2>/dev/null 127 134 sleep 30 128 135 break 129 136 fi
+5 -17
fedac/native/src/js-bindings.c
··· 3317 3317 ac_log("[reboot] executing reboot syscall"); 3318 3318 ac_log_flush(); 3319 3319 3320 - if (getpid() == 1) { 3321 - reboot(LINUX_REBOOT_CMD_RESTART); 3322 - } else { 3323 - // Under cage: tell PID 1 to reboot, then exit so cage closes 3324 - kill(1, SIGUSR2); // SIGUSR2 = reboot request 3325 - _exit(0); 3326 - } 3320 + // Exit with code 2 — init script sees this as reboot request 3321 + _exit(2); 3327 3322 return JS_UNDEFINED; 3328 3323 } 3329 3324 ··· 3339 3334 ac_log("[poweroff] pid=%d, syncing filesystems...\n", getpid()); 3340 3335 ac_log_flush(); 3341 3336 sync(); usleep(300000); sync(); 3342 - ac_log("[poweroff] executing power off...\n"); 3337 + ac_log("[poweroff] exiting with code 0 (init will power off)...\n"); 3343 3338 ac_log_flush(); 3344 - if (getpid() == 1) { 3345 - int r = reboot(LINUX_REBOOT_CMD_POWER_OFF); 3346 - ac_log("[poweroff] reboot() returned %d errno=%d\n", r, errno); 3347 - } else { 3348 - // Under cage: tell PID 1 to power off, then exit so cage closes 3349 - ac_log("[poweroff] sending SIGTERM to PID 1\n"); 3350 - kill(1, SIGTERM); 3351 - _exit(0); 3352 - } 3339 + // Exit cleanly — init script sees exit code 0 and runs poweroff 3340 + _exit(0); 3353 3341 return JS_UNDEFINED; 3354 3342 } 3355 3343