homeGeek CultureWebstoreeCards!Forums!Joy of Tech!AY2K!webcam

Forum Home Post A Reply

my profile | directory login | | search | faq | forum home


» The Geek Culture Forums » Techno-Talking » Math-a-holics and Code Junkies » exit init without kernel panic » Post A Reply


Post A Reply
Login Name:
Password (max 13 characters):
Message Icon: Icon 1     Icon 2     Icon 3     Icon 4     Icon 5     Icon 6     Icon 7    
Icon 8     Icon 9     Icon 10     Icon 11     Icon 12     Icon 13     Icon 14    
Message:

HTML is not enabled.
UBB Code™ is enabled.

 

Instant Graemlins Instant UBB Code™
Smile   Frown   Embarrassed   Big Grin   Wink   Razz  
Cool   Roll Eyes   Mad   Eek!   Confused   Happytears  
blush   Beard of Peter Gabriel!   crazy   tired   ohwell   evil  
shake head   cry baby   hearts   weep   devil wand   thumbsup  
thumbsdown   Geek   Applause   Angel   Envy    
Insert URL Hyperlink - UBB Code™   Insert Email Address - UBB Code™
Bold - UBB Code™   Italics - UBB Code™
Quote - UBB Code™   Code Tag - UBB Code™
List Start - UBB Code™   List Item - UBB Code™
List End - UBB Code™   Image - UBB Code™

What is UBB Code™?
Options


Disable Graemlins in this post.


 


T O P I C     R E V I E W
nerdwithnofriends
Member # 3773
 - posted April 11, 2005 21:20
Hello, all, it's me again. Pretty simple question this time: how does the init process on a linux system tell the kernel that the machine is ready to shut down? init isn't allowed to simply exit, else the kernel raises a panic.
Thanks abunch!
 
quantumfluff
Member # 450
 - posted April 12, 2005 06:31
I believe it exits. init waits for all it's children to die, leaving itself as the only process running. When it exits, the kernel has 0 processes left, and halts. Of course, last time I read kernel sources seriously was in 1980, so I could be wrong by now.
 
Brother Dysk
Member # 3777
 - posted April 12, 2005 08:32
That sounds dubious, given that Linux did not exist in 1980. I assume this was some other UNIX, then?
 
quantumfluff
Member # 450
 - posted April 12, 2005 10:32
Linux borrows a huge amount from various traditional unixes. I don't remember if it was BSD 2.11 or ATT V7 which I was using at the time. Still, if you must be certain, "Use the source Luke"
 
n4dmx
Member # 3177
 - posted April 12, 2005 14:56
Init controls the runlevel scripts, among other things.

When you shutdown, init tells the system to run the script "rc.0" or something similar (depending on the distro) which will send the system into runlevel 0, stopping all processes.

Type "telinit 0" at the command line, or "init 0" if that didn't work to see what happens (be root for this). [Smile]
 
drunkennewfiemidget
Member # 2814
 - posted April 12, 2005 16:15
When you shut down the system, init is called with a runlevel of (usually) 0. (telinit 0 to try that out, as someone else already said). When init enters a runlevel of 0, it shuts down all programs and services, then it sends a TERM signal to all programs still remaining, gives them a few seconds to die cleanly, and then sends a KILL to them so they go away no matter what. the linux kernel code simply does an execve of init() and if it ever returns, it panics, so I'd imagine shutdown would kill everything so that only itself and init continues to run, and then sits in an endless loop..

If you want to test that, compile your kernel with sysrq, and then do a shutdown -h now (preferably without apm enabled so it doesn't automatically shut your box off for you), and then type ALT-SYSRQ-P and it will show you what the current process running is.. is it always shutdown?
 
nerdwithnofriends
Member # 3773
 - posted April 12, 2005 19:33
alright everybody, i'm not retarded when it comes to shutting down a linux system. I was just wondering what exactly went into it...
anyways, i think i'll try what drunknewf said. I tried writing a really simple C program that used the exit() system call instead of just returning zero.
it didn't work.
I'm thinking the infinite loop thing is the way to go, i'll have to give it a try and get back to y'all.
 
nerdwithnofriends
Member # 3773
 - posted April 12, 2005 19:35
okay, i guess i'll share what i've learned.
init controls EVERYTHING. shutdown /reboot/ telinit are just control programs that write to /dev/initctl, which is a FIFO. init reads this and does various actions depending on what the control program writes to teh FIFO.
looking at the SysVInit sources, i think it just enters an infinite loop when it shuts down and the kernel sees this and turns off the machine.
 




Contact Us | Geek Culture Home Page

© 2015 Geek Culture

Powered by Infopop Corporation
UBB.classicTM 6.4.0



homeGeek CultureWebstoreeCards!Forums!Joy of Tech!AY2K!webcam