I'm implementing a Reboot() call in my application. It's an embedded application, so no console, keyboard or power switch. The Reboot() must eventually restart the system no matter what. Ideally, I want it to fail gracefully.

I've had systems in the past cause problems where a call to reboot or shutdown did not result in a reboot of the machine. e.g. failure to sync drives, unmount a removed USB flash drive.

My system is embedded, with a read-only mounted root filing system, so a sudden power off isn't a big issue. But I do write logs to a Flash disc and I'd like to preserve this as much as possible.

My current Reboot() looks like this:

void Reboot()
    system( "reboot" );     // try the reboot
    system( "reboot -f" );      // force
    system( "reboot -f -n" );   // force and don't try to sync
    system( "kill 1" );     // process 1 is the root process of all

The reset command is a hard system reset that will not fail. The system also has a Watchdog timer.

Would people care to comment on anything to add/replace/change in my Reboot() function?

e.g. should I use Magic SysRq?

  • what about init 6 ?
    – rkosegi
    Sep 17, 2012 at 11:38
  • Sorry, I should have specified that I'm running Busybox. No run levels. But changing the run level, and calling the kill scripts just calls reboot command in the end anyway.
    – Mr Stinky
    Sep 17, 2012 at 12:07

1 Answer 1


The system also has a Watchdog timer.

I think this is your answer - flush the block cache and stop kicking the watchdog. I've worked on many embedded systems, and can't recall one that performed a reboot using the traditional server/PC mechanisms.

  • I'm pretty sure my Reset() function uses the Watchdog to reboot the system. The point of the question was to see if I could do anything better before I forced the reboot (via the watchdog).
    – Mr Stinky
    May 30, 2017 at 12:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .