int reboot_now(void) { /* We need to sleep for just a little to allow the CGI's to finish */ sleep(1); /* Don't kill ourself */ signal(SIGTERM,SIG_IGN); signal(SIGHUP,SIG_IGN); setpgrp(); sync(); /* Send signals to every process _except_ pid 1 */ kill(-1, SIGTERM); sleep(1); sync(); kill(-1, SIGKILL); sleep(1); sync(); #if !defined(__UC_LIBC__) && (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,11)) { extern int bdflush(int func, long data); /* bdflush, kupdate not needed for kernels >2.2.11 */ bdflush(1, 0); sync(); } #endif init_reboot(RB_AUTOBOOT); return(-1); /* Shrug */ }
int reboot_now(void) { /** * Write the current date/time to the RTC */ #ifdef CONFIG_USER_HWCLOCK_HWCLOCK system("hwclock --systohc --utc"); #elif defined(CONFIG_USER_RTC_M41T11) || defined (CONFIG_USER_RTC_DS1302) system("rtc -w"); #else /* We need to sleep for just a little to allow the CGI's to finish * The RTC commands above already take a little while, so * only sleep if we don't have any RTC command to run */ sleep(1); #endif /* Don't kill ourself */ signal(SIGTERM,SIG_IGN); signal(SIGHUP,SIG_IGN); setpgrp(); sync(); #ifdef CONFIG_USER_INIT_INIT /* Stop init from respawning daemons */ kill(1, SIGTSTP); #endif /* Send signals to every process _except_ pid 1 */ kill(-1, SIGTERM); sleep(1); sync(); kill(-1, SIGKILL); sleep(1); #if defined(CONFIG_USER_MOUNT_UMOUNT) || defined (CONFIG_USER_BUSYBOX_UMOUNT) system("/bin/umount -a -r"); #endif sync(); #if !defined(__UC_LIBC__) && (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,11)) { extern int bdflush(int func, long data); /* bdflush, kupdate not needed for kernels >2.2.11 */ bdflush(1, 0); sync(); } #endif init_reboot(RB_AUTOBOOT); return(-1); /* Shrug */ }
extern int reboot_main(int argc, char **argv) { char *delay; /* delay in seconds before rebooting */ if(bb_getopt_ulflags(argc, argv, "d:", &delay)) { sleep(atoi(delay)); } #ifdef CONFIG_USER_INIT /* Don't kill ourself */ signal(SIGTERM,SIG_IGN); signal(SIGHUP,SIG_IGN); setpgrp(); /* Allow Ctrl-Alt-Del to reboot system. */ init_reboot(RB_ENABLE_CAD); message(CONSOLE|LOG, "\n\rThe system is going down NOW !!\n"); sync(); /* Send signals to every process _except_ pid 1 */ message(CONSOLE|LOG, "\rSending SIGTERM to all processes.\n"); kill(-1, SIGTERM); sleep(1); sync(); message(CONSOLE|LOG, "\rSending SIGKILL to all processes.\n"); kill(-1, SIGKILL); sleep(1); sync(); init_reboot(RB_AUTOBOOT); return 0; /* Shrug */ #else return kill_init(SIGTERM); #endif }
static int shutdown_now(int rb_which) { /** * Save us some entropy over this event */ logd("entropy", NULL); /** * Write the current date/time to the RTC */ #ifdef CONFIG_USER_HWCLOCK_HWCLOCK system("hwclock --systohc --utc"); #elif defined(CONFIG_USER_RTC_M41T11) || defined (CONFIG_USER_RTC_DS1302) system("rtc -w"); #else /* We need to sleep for just a little to allow the CGI's to finish * The RTC commands above already take a little while, so * only sleep if we don't have any RTC command to run */ sleep(1); #endif /* Don't kill ourself */ signal(SIGTERM,SIG_IGN); signal(SIGHUP,SIG_IGN); setpgrp(); sync(); #ifdef CONFIG_USER_INIT_INIT /* Stop init from respawning daemons */ kill(1, SIGTSTP); #endif /* Send signals to every process _except_ pid 1 */ kill(-1, SIGTERM); sleep(1); sync(); kill(-1, SIGKILL); sleep(1); #if defined(CONFIG_USER_MOUNT_UMOUNT) || defined (CONFIG_USER_BUSYBOX_UMOUNT) system("/bin/umount -a -r"); #endif sync(); #if !defined(__UC_LIBC__) && (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,11)) { extern int bdflush(int func, long data); /* bdflush, kupdate not needed for kernels >2.2.11 */ bdflush(1, 0); sync(); } #endif #ifdef CONFIG_LEDMAN /* We want to turn off all LEDs, except the POWER LED, * so it is clear that we are shut down. Enable the ALT functionality * for the POWER LED and then turn all std LEDs off. */ ledman_cmd(LEDMAN_CMD_ALT_ON, LEDMAN_POWER); ledman_cmd(LEDMAN_CMD_ON | LEDMAN_CMD_ALTBIT, LEDMAN_POWER); ledman_cmd(LEDMAN_CMD_OFF, LEDMAN_ALL); #endif #ifdef CONFIG_SNAPDOG /* Turn off user servicing of the watchdog */ write(open("/dev/watchdog", O_WRONLY), "V", 1); #endif init_reboot(rb_which); return -1; /* Shrug */ }
extern int reboot_main(int argc, char **argv) { int delay = 0; /* delay in seconds before rebooting */ int rc; while ((rc = getopt(argc, argv, "d:")) > 0) { switch (rc) { case 'd': delay = atoi(optarg); break; default: show_usage(); break; } } if(delay > 0) sleep(delay); #ifdef CONFIG_USER_INIT_INIT /* Don't kill ourself */ signal(SIGTERM,SIG_IGN); signal(SIGHUP,SIG_IGN); setpgrp(); /* Allow Ctrl-Alt-Del to reboot system. */ init_reboot(RB_ENABLE_CAD); message("\n\rThe system is going down NOW !!\n"); sync(); /* Send signals to every process _except_ pid 1 */ message("\rSending SIGTERM to all processes.\n"); kill(-1, SIGTERM); sleep(1); sync(); message("\rSending SIGKILL to all processes.\n"); kill(-1, SIGKILL); sleep(1); sync(); if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,2,11)) { /* bdflush, kupdate not needed for kernels >2.2.11 */ bdflush(1, 0); sync(); } init_reboot(RB_AUTOBOOT); exit(0); /* Shrug */ #else #ifdef BB_FEATURE_LINUXRC { /* don't assume init's pid == 1 */ long *pid = find_pid_by_name("init"); if (!pid || *pid<=0) pid = find_pid_by_name("linuxrc"); if (!pid || *pid<=0) error_msg_and_die("no process killed"); fflush(stdout); return(kill(*pid, SIGTERM)); } #else // yachen *(unsigned int volatile *)(0xfff8101c) = 0x82; return(kill(1, SIGTERM)); #endif #endif }