util: halt should not power off system unless called with -p/--poweroff

Bug #532366 reported by Daniel Richard G. on 2010-03-05
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
upstart
Low
Scott James Remnant
upstart (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: upstart

This concerns upstart 0.6.3-11 in Karmic.

I see that halt(8), by default, powers off the system. (I don't agree with this, but it's been like this for four years, so whatever.) halt(8) has an option -p/--poweroff to request a poweroff (but this option is superfluous, because that's the default). There is no option, however, to have halt(8) do a system halt. The only way to get a proper halt is "shutdown -h -H ...", the need for which negates the utility of the halt/poweroff/reboot trio of commands.

I would like to request this new option to halt(8) (e.g. -h/--halt), and maybe drop the -p/--poweroff option lest it mislead the user as to the command's default behavior.

Actually I agree with you, halt should not power off the system - that's the entire reason there are two names for this binary. It looks like a simple bug in the code when halt actually calls shutdown, and doesn't pass across the argument to mean that it was really called as halt.

Changed in upstart (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
summary: - halt(8) needs option to request halt instead of poweroff
+ util: halt should not power off system unless called with -p/--poweroff
Changed in upstart (Ubuntu):
status: Confirmed → Triaged
importance: Medium → Low

                switch (mode) {
                case REBOOT:
                        args[i++] = "-r";
                        break;
                case HALT:
                        args[i++] = "-h";
                        break;
                case POWEROFF:
                        args[i++] = "-h";
                        args[i++] = "-P";
                        break;
                }

The HALT case should pass the -H (called as halt) argument to shutdown, just as the POWEROFF case passes -P

Changed in upstart:
importance: Undecided → Low
status: New → Triaged
Daniel Richard G. (skunk) wrote :

Oh... okay. I thought, from looking at Bug #59720 (esp. comment #2) that it had been long ago decided that "halt" should act like "poweroff". Not to mention the observation that selecting "Shutdown" in the GNOME desktop's corner menu would initiate a halt rather than a poweroff, according to the message wall'ed to all terminals. (I guess I should file a bug against gnome-power-manager for that?)

That aside, I'm happy to see halt(8) get back to halting again :-)

On Fri, 2010-03-05 at 17:52 +0000, Daniel Richard G. wrote:

> Oh... okay. I thought, from looking at Bug #59720 (esp. comment #2) that
> it had been long ago decided that "halt" should act like "poweroff".
>
It was a last-minute fix for edgy, which had a fairly hacky interaction
between reboot/halt/poweroff and shutdown - and didn't properly deal
with the default for "-h"

I'd always intended to revert that once the interaction was fixed, but
forgot.

Since shutdown now correctly passes INIT_HALT=HALT or INIT_HALT=POWEROFF
when called with "-H" and "-P" (and neither - allowing the default to
take precedence when just "-h") - there's no reason for the hack.

halt should halt (shutdown -h -H now),
poweroff should poweroff (shutdown -h -P now),
shutdown -h now should do whatever is configured as the default.

> Not to mention the observation that selecting "Shutdown" in the GNOME
> desktop's corner menu would initiate a halt rather than a poweroff,
> according to the message wall'ed to all terminals. (I guess I should
> file a bug against gnome-power-manager for that?)
>
Right, if that's using the halt/poweroff wrappers for shutdown, that's a
bug!

Scott
--
Have you ever, ever felt like this?
Had strange things happen? Are you going round the twist?

Daniel Richard G. (skunk) wrote :

Ah, okay, now I understand what had happened. Thanks for the explanation!

I'll have a closer look at what GNOME is doing, especially in light of the various ways of bringing down the system....

For sanity's sake, I'm closing the Ubuntu tasks for upstream Upstart bugs. I've experimented with having both, but it is just making bugs hard to find now. Will use the policy whereby bugs on the Ubuntu package exist in the Ubuntu packaging or patches only, any bugs in the Upstart code are Upstream bugs.

Changed in upstart (Ubuntu):
status: Triaged → Invalid
Scott James Remnant (scott) wrote :
Changed in upstart:
assignee: nobody → Scott James Remnant (scott)
milestone: none → 1.1
status: Triaged → Fix Committed
Changed in upstart:
status: Fix Committed → Fix Released
Changed in upstart (Ubuntu):
status: Invalid → New
importance: Low → Undecided
Steve Langasek (vorlon) wrote :

1.1 is included in oneiric.

Changed in upstart (Ubuntu):
status: New → Fix Released
Daniel Richard G. (skunk) wrote :

I've confirmed that this is good in Oneiric. Thank you, Scott and Steve.

I would suggest updating the comment in /etc/default/halt, currently

    # Default behaviour of shutdown -h / halt. Set to "halt" or "poweroff".

so that it doesn't imply to affect the behavior of halt(8). ("shutdown -h" is the one that can go either way.)

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers