APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

Should 'halt' call 'shutdown'?

© February 2006 Anthony Lawrence

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

-> Should 'halt' call 'shutdown'?

1 comment

Inexpensive and informative Apple related e-books:

El Capitan: A Take Control Crash Course

Take Control of High Sierra

Take Control of Preview

iOS 10: A Take Control Crash Course

Take Control of Upgrading to El Capitan

More Articles by © Anthony Lawrence


Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Printer Friendly Version

The Analytical Engine has no pretentions whatever to originate anything. It can do whatever we know how to order it to perform. (Ada Lovelace)

Linux posts

Troubleshooting posts

This post tagged:




Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode