As mentioned briefly in the comments section of Bootstrapping your Linux Machine, recent Linux systems have added a convenience feature to the 'halt' and 'reboot' commands: they actually call 'shutdown' if the system isn't in init state 0 or 6.
You can override this behaviour with "-f" or use 'poweroff', but I'm not entirely sure that this was a good idea to start with.
The purpose of 'shutdown' is to bring the system down cleanly. It should kill off user processes gently (starting with SIGTERM so that processes that trap that can clean up open files, etc.) and it should then have 'init' change run levels so that appropriate scripts can run to do other cleanup.
This is all to the good. It's the way a system should be brought down under normal circumstances, so having 'halt' and 'reboot' invoke 'shutdown' is certainly helpful for the naive user who doesn't understand what should be done to bring down a system. But should traditional commands be perverted to prevent naive users from damaging systems?
Maybe. Unfortunately people were probably using 'halt' and 'reboot' before that change was made, and few of them probably read the man pages to understand what they really did. But I have to say that it bothers me: pandering to ignorance doesn't seem right. Maybe a shell function that warned "You probably want shutdown; shall I run that instead?" would have been a better idea - leave the commands as we cranky old folks expect them to be and educate the newbies. That seems like a better path to me. Even better might have been to build the warning into 'consolehelper' (read the man page if you don't know what this is).
The perversion of halt also originally led to the "poweroff" problem described at Power off and kernels version 2.1.xx and 2.2.xx. At that time, you couldn't use 'halt -p' because the '-p' (poweroff) option would get lost on the way through 'shutdown'. That problem doesn't exit on my RedHat system: 'halt -p' properly powers off, but the article still shows the kind of things that can happen when someone decides (probably correctly, unfortunately) that they should protect users from their own lack of knowledge.
Incidentally, Mac OS X keeps a more traditional halt. It kills processes, and syncs discs. If invoked with -q it doesn't kill processes, and if you give it -n it doesn't sync either. Now that's a halt that does what it is told! SCO OSR5 doesn't have halt; they have 'haltsys', which only syncs and actually just calls a more general purpose uadmin.
Overall, it's a tough call. New and improved sometimes is better, sometimes isn't, and sometimes I just can't make up my mind. This certainly is one of those cases.
Got something to add? Send me email.
(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version
Increase ad revenue 50-250% with Ezoic