Skip to contentSkip to conversation

halt: init exits/panic

DISCUSSION Nico Schottelius 3 participants 7 messages Jul 9, 2005 – Oct 4, 2005

lore
Share & tools
lore
#0 lore raw

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.

Should init simply sleep, return to normal processing or exit?

Sincerly,

Nico

Signature · 3 lines
Keep it simple & stupid, use what's available.
Please use pgp encryption: 8D0E 27A4 is my id.
http://nico.schotteli.us | http://linux.schottelius.org
#1 lore raw

Hi Nico :)

* Nico Schottelius <[email protected]> dixit:

Quoted 2 lines

What's the 'correct behaviour' of an init system, if someone wants to shutdown the system?

What I do in my vcinit, the last steps I mean, is:

reboot(RB_POWER_OFF); /* If halting*/
or
reboot(RB_AUTOBOOT); /* If rebooting */

exit(EXIT_SUCCESS);

And my vcinit doesn't panic ;)

Raúl Núñez de Arenas Coronado

Signature · 3 lines
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...
#2 lore raw
In reply to Nico Schottelius
Quoted 5 lines · Nico Schottelius

Hello!

What's the 'correct behaviour' of an init system, if someone wants to shutdown the system?

Quoted 7 lines

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?

Signature · 2 lines
Coywolf Qi Hunt
http://ahbl.org/~coywolf/
#3 lore raw

Sorry for the delay.

Coywolf Qi Hunt [Sun, Jul 10, 2005 at 01:09:22AM +0800]:

Quoted 8 lines · Nico Schottelius
Quoted 7 lines

Hello!

What's the 'correct behaviour' of an init system, if someone wants to shutdown the system?

I currently do:

Quoted 7 lines
Quoted 5 lines

- 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?

"Attempted to kill init!"

--> Panic.

Nico

Signature · 2 lines
Latest project: cconfig (http://nico.schotteli.us/papers/linux/cconfig/)
Open Source nutures open minds and free, creative developers.
#4 lore raw
In reply to Coywolf Qi Hunt

Coywolf Qi Hunt [Sun, Jul 10, 2005 at 01:09:22AM +0800]:

Quoted 8 lines · Nico Schottelius
Quoted 7 lines

Hello!

What's the 'correct behaviour' of an init system, if someone wants to shutdown the system?

I currently do:

Quoted 7 lines
Quoted 5 lines

- 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

Signature · 2 lines
Latest project: cconfig (http://nico.schotteli.us/papers/linux/cconfig/)
Open Source nutures open minds and free, creative developers.
#5 lore raw
Quoted 17 lines · Nico Schottelius

Coywolf Qi Hunt [Sun, Jul 10, 2005 at 01:09:22AM +0800]:

Quoted 8 lines · Nico Schottelius
Quoted 7 lines

Hello!

What's the 'correct behaviour' of an init system, if someone wants to shutdown the system?

I currently do:

Quoted 7 lines
Quoted 5 lines

- 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?

Quoted 7 lines

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/

#6 lore raw

Coywolf Qi Hunt [Tue, Oct 04, 2005 at 04:12:40PM +0800]:

Quoted 23 lines · Nico Schottelius
Quoted 22 lines

Coywolf Qi Hunt [Sun, Jul 10, 2005 at 01:09:22AM +0800]:

Quoted 8 lines · Nico Schottelius
Quoted 7 lines

Hello!

What's the 'correct behaviour' of an init system, if someone wants to shutdown the system?

I currently do:

Quoted 7 lines
Quoted 5 lines

- 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)

Quoted 6 lines
Quoted 2 lines

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

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