1. 如果有大电容,检测到断电后先做dismount,然后再走标准关机流程。
#!/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binmount -o remount,ro /
umount -f -a -r > /dev/null 2>&1
fp = popen("ps -e | grep \'app\' | awk \'{print $1}\'", "r");va = fgets(buffer, sizeof(buffer), fp);pclose(fp);if (va == NULL){printf("GET PID ERROR\n");} else {printf("GET PID : %s\n", buffer);pid = atoi(buffer);printf("pid : %d\n", pid);kill(pid, SIGUSR1);printf("-Send signal to app---\n");usleep(1000000);}kill(-1, SIGKILL);usleep(10000);sync();system("umountall.sh");reboot(RB_POWER_OFF);while (1)usleep(10000000);
2. 把rootfs做成只读的,单独开个需要写的分区。开机后对这个分区做fsck。