Hi,

I'm trying to use a call to reboot() to reboot the system after my program completes, however it seems that it takes a few seconds before the reboot actually happens. Why is this so?

My sample code is as follows:

Code:
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <time.h>
#include <ctype.h>
#include <unistd.h>
#include <linux/reboot.h>

// Function prototypes
int restart(int delay);
int main(void);

int restart(int delay)
{
	sleep(delay);
	return reboot(LINUX_REBOOT_CMD_RESTART);
}

int main(void)
{
	printf("Rebooting...");
	fflush(stdout);
	restart(0);
	return 0;
}
After the "Rebooting..." is printed out, it takes a few seconds before the system reboots itself, even though I've specified 0 second sleep. Why is this so?