I have 2 machines running linux.
In one machine, the reboot command is an executable normally found in all linux distributions.
In the second machine the reboot command is a shell script customized using some other hardware tool commands to reboot the system.
One behavior difference between the two machines is that when I execute the reboot
command on the first machine, it shows another shell prompt and then reboots.
But in the case of second machine, it reboots without showing a shell prompt. I expect the second machine to behave the same way as first machine when reboot command is given.
Currently I am analyzing the source code of shutdown.c
and halt.c
normally found in linux distributions, so that I can find out the implementation which produces the shell propmt on reboot and use that in the shell script in second machine.
Kindly give me some pointers on where I should start looking to find the implementation.
Thanks
Use
shutdown -r
instead. It's historically been used throughout various unices, so I believe its interface and behavior are more commonly known and predictable.My guess is that the program double forks itself into the background.
I expect that the program which returns you to the prompt is not actually doing anything itself, but rather communicating with your init daemon (sysvinit or upstart or whatever is running as process 1) and asking it to shut down the system. The other script is just a normal script.
The Linux kernel is what issues the final syscalls to reboot the machine, not the userland. Likely, the kernel internally uses IPMI to reboot the machine. Systems have different approaches to powering down and rebooting. I've run across a few that require you to kick a pin on the RTC in order to reboot the system, and that's exactly what the kernel does for that machine.
What's the machine's architecture? ARM, MIPS, other? WindRiver is the developer behind VxWorks if I am not mistaken. You can probably call their support people and see if they can assist you as well.