Linux shutdown/reboot process
Peter Teoh
htmldeveloper at gmail.com
Tue May 15 01:09:23 EDT 2012
i think your question is distro-specific, or at least it differs
between sysvinit and systemd - which is the two main technique of
starting up.
For Fedora Core 17 beta (my system), it is running systemd:
http://lwn.net/Articles/458789/
and here it shows all the good points about systemd:
http://0pointer.de/blog/projects/why.html
(noting the shutdown features if u are focusing on the shutdown part).
more info:
https://fedoraproject.org/wiki/Systemd
[PDF]
Beyond Init: systemd - LinuxKongress 2010
www.linux-kongress.org/2010/slides/systemd-poettering.pdf
But as mentioned in document above, /dev/initctl is still supported,
which is the traditional means of shutting down.
In Ubuntu (which uses sysvinit, and shutting down is via
/dev/initctl), u can get the source code for poweroff via:
"apt-get source upstart"
and then start navigating through the source code.
Within util/shutdown.c you can see following:
* struct request:
*
* This is the structure passed across /dev/initctl.
**/
struct request {
int magic;
int cmd;
int runlevel;
int sleeptime;
char data[368];
};
/**
* sysvinit_shutdown:
*
* Attempt to shutdown a running sysvinit /sbin/init using its /dev/initctl
* socket.
**/
static void
sysvinit_shutdown (void)
{
struct sigaction act;
struct request request;
int fd;
/* Fill in the magic values */
memset (&request, 0, sizeof (request));
request.magic = 0x03091969;
request.sleeptime = 5;
request.cmd = 1;
/* Select a runlevel based on the event name */
There goes all the magic....or some part of it....
On Mon, May 14, 2012 at 7:31 PM, Asutosh Das <das.asutosh at gmail.com> wrote:
>
> Hi List
> I have a query about the linux shutdown or reboot process.
>
> Please can you let me know if the below sequence is correct:
>
> When reboot command is given on the shell:
>
> 1. all user-space process is frozen (by sending some signal ?? )
> 2. all file-systems are remounted as read-only - (sysrq handler does this ?? )
> 3. all drivers, whose shutdown handlers have been defined, are called
> in the reverse order in which these drivers were initialized.
>
> I am not sure what happens after this.
>
> TIA.
>
>
>
> --
> Thanks & Regards
> ~/asd
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
--
Regards,
Peter Teoh
More information about the Kernelnewbies
mailing list