Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Somehow I've never considered what will happen on Unix if pid 1 exits!

Even though I'm pretty sure I've run with init=/bin/sh and then typed "exit" at some point in my single-user session, I have absolutely no recollection of the results. I should try it on a few OSes and see!



If PID 1 exits, the system usually panics immediately and restarts.



"...and that's why we have to put half a million lines of C in PID 1"


i'm reasonably sure that kill -1 1 used to be a canonical way to `halt`


I used to work with a long-time AIX kernel developer. His method of shutting off his machine was "sync; sync; kill -9 1".

Of course, his method of preparing to move offices (a common occurrence at IBM) was to

1. Take his (RS-6000) workstation home with him the night of the move.

2. Otherwise, just lock his desk.

He didn't have anything in his office but his chair, desk, and workstation.


As a random trivia about sysadmins: the reason he sync-ed twice is not because "twice is better than once, just to make sure".

Sync is not synchronous. When it is back to the shell there is no guarantee that data in memory is fully copied to disk.

However, it sets a flag that is reset when the copying is done. Sync will hang if the flag is set.

So the first sync arms the copy and sets the flag and is back to the shell.

The second sync starts, blocks at the flag. The flag gets reset and it is back to the shell.

So the 2nd sync going back to the shell is a guarantee that the first sync is fine and data is safe


Heck, you wrote an init on bash with the LNX-BBC (at least in some versions of it).


I'm pretty sure psdoom warns you against killing init




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: