Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
what about init 6 ? – rkosegi Sep 17 '12 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 '12 at 12:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.