2005-10-04 07:37:44

by Nico Schottelius

[permalink] [raw]
Subject: Re: halt: init exits/panic

Coywolf Qi Hunt [Sun, Jul 10, 2005 at 01:09:22AM +0800]:
> On 7/9/05, Nico Schottelius <[email protected]> wrote:
> > Hello!
> >
> > What's the 'correct behaviour' of an init system, if someone wants
> > to shutdown the system?
> >
> > I currently do:
> >
> > - call reboot(RB_POWER_OFF/RB_AUTOBOOT/RB_HALT_SYSTEM)
> > - _exit(0)
> >
> > Is this exit() call wrong? If I do RB_HALT_SYSTEM and _exit(0) after,
> > the kernel panics.
>
> What the panic shows?

To be fully correct:

"Kernel panic - not syncing: Attempted to kill init" (from the last time
I tried, 2.6.13.2)

Perhaps _exit(0) is not correct for an init system?
This at least explains why it always looks like nothing is synced.

Nico

--
Latest project: cconfig (http://nico.schotteli.us/papers/linux/cconfig/)
Open Source nutures open minds and free, creative developers.


Attachments:
(No filename) (853.00 B)
signature.asc (827.00 B)
Digital signature
Download all attachments

2005-10-04 08:12:43

by Coywolf Qi Hunt

[permalink] [raw]
Subject: Re: halt: init exits/panic

On 10/4/05, Nico Schottelius <[email protected]> wrote:
> Coywolf Qi Hunt [Sun, Jul 10, 2005 at 01:09:22AM +0800]:
> > On 7/9/05, Nico Schottelius <[email protected]> wrote:
> > > Hello!
> > >
> > > What's the 'correct behaviour' of an init system, if someone wants
> > > to shutdown the system?
> > >
> > > I currently do:
> > >
> > > - call reboot(RB_POWER_OFF/RB_AUTOBOOT/RB_HALT_SYSTEM)
> > > - _exit(0)
> > >
> > > Is this exit() call wrong? If I do RB_HALT_SYSTEM and _exit(0) after,
> > > the kernel panics.
> >
> > What the panic shows?
>
> To be fully correct:
>
> "Kernel panic - not syncing: Attempted to kill init" (from the last time
> I tried, 2.6.13.2)
>
> Perhaps _exit(0) is not correct for an init system?
> This at least explains why it always looks like nothing is synced.

Right. init(8) should not call _exit() or exit(). Otherwise you'll get
that panic. It's OK for *another* process, reboot(8) to call reboot(2)
and then exit(). You should follow this way.
--
Coywolf Qi Hunt
http://sosdg.org/~coywolf/

2005-10-04 10:55:58

by Nico Schottelius

[permalink] [raw]
Subject: Re: halt: init exits/panic

Coywolf Qi Hunt [Tue, Oct 04, 2005 at 04:12:40PM +0800]:
> On 10/4/05, Nico Schottelius <[email protected]> wrote:
> > Coywolf Qi Hunt [Sun, Jul 10, 2005 at 01:09:22AM +0800]:
> > > On 7/9/05, Nico Schottelius <[email protected]> wrote:
> > > > Hello!
> > > >
> > > > What's the 'correct behaviour' of an init system, if someone wants
> > > > to shutdown the system?
> > > >
> > > > I currently do:
> > > >
> > > > - call reboot(RB_POWER_OFF/RB_AUTOBOOT/RB_HALT_SYSTEM)
> > > > - _exit(0)
> > > >
> > > > Is this exit() call wrong? If I do RB_HALT_SYSTEM and _exit(0) after,
> > > > the kernel panics.
> > >
> > > What the panic shows?
> >
> > To be fully correct:
> >
> > "Kernel panic - not syncing: Attempted to kill init" (from the last time
> > I tried, 2.6.13.2)
> >
> > Perhaps _exit(0) is not correct for an init system?
> > This at least explains why it always looks like nothing is synced.
>
> Right. init(8) should not call _exit() or exit(). Otherwise you'll get
> that panic. It's OK for *another* process, reboot(8) to call reboot(2)
> and then exit(). You should follow this way.

Ok, as far as I understood my init simply returns to its normal state
and hopes that the kernel halts|reboots|powers off.

Will do that' thanks for the info.

Nico

--
Latest project: cconfig (http://nico.schotteli.us/papers/linux/cconfig/)
Open Source nutures open minds and free, creative developers.


Attachments:
(No filename) (1.39 kB)
signature.asc (827.00 B)
Digital signature
Download all attachments