#include <sys/reboot.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <signal.h>
#include "procd.h"
#include "syslog.h"
static void state_enter(void)
{
+ char ubus_cmd[] = "/sbin/ubusd";
switch (state) {
case STATE_EARLY:
LOG("- init -\n");
service_init();
- service_start_early("ubus", "/sbin/ubusd");
+ service_start_early("ubus", ubus_cmd);
procd_inittab();
procd_inittab_run("respawn");
break;
case STATE_HALT:
+ LOG("- SIGTERM processes -\n");
+ kill(-1, SIGTERM);
+ sync();
+ sleep(1);
+ LOG("- SIGKILL processes -\n");
+ kill(-1, SIGKILL);
+ sync();
+ sleep(1);
LOG("- reboot -\n");
reboot(reboot_event);
break;
void procd_shutdown(int event)
{
+ if (state >= STATE_SHUTDOWN)
+ return;
DEBUG(2, "Shutting down system with event %x\n", event);
reboot_event = event;
state = STATE_SHUTDOWN;