Bug 475227

Summary: shutdown ignores requested halt action
Product: [Fedora] Fedora Reporter: Bill Nottingham <notting>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: cdahlin, dshaw, notting, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 8.86.3-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-12-09 15:28:28 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bill Nottingham 2008-12-08 15:45:33 UTC
+++ This bug was initially created as a clone of Bug #475006 +++

Created an attachment (id=326004)
create /halt file if halt action was requested

When you request a halt action
/sbin/shutdown -h -H now
instead of halting system gets powered down

The problem comes from SysVinit-2.86-14

/etc/init.d/halt from initscripts-8.45.19.1.EL-1 has this line of code

[ -f /poweroff -o ! -f /halt ] && HALTARGS="$HALTARGS -p"

Which makes poweroff a default action in absence of /halt file. In my opinion this assumption is questionable for servers. Usually, after a power failure if a system BIOS has "Power recovery: LAST" setting, system can start automatically after power returns. If the action during shutdown was poweroff it would never happen, somebody would have to go to the server and press the power button. 

But back to shutdown problem. 
when /sbin/halt is called it properly creates /halt file if -p switch (power off) was not passed, so for /sbin/halt halt is default action, proper behavior, in my opinion. But when /sbin/shutdown called with -H switch it doesn't create /halt file, which it should.

Proposed patch is attached. I removed "usage" comment because it is not in sync with the actual source code

--- Additional comment from chepkov on 2008-12-06 17:10:41 EDT ---

Unfortunately, the approach doesn't work on kernel-xen. 
First, strcmp(halttype,HALT) code causes segmentation fault, because halttype
is uninitialized. But even after I fixed that, still kernel-xen powers down.

so, to reiterate the problem

/sbin/shutdown -h -H now doesn't halt the system

if on plain kernel you do touch /halt first, system halts as expected. No
workaround for kernel-xen

Comment 1 Bill Nottingham 2008-12-08 20:45:51 UTC
shutdown lives in upstart these days.

Comment 2 Casey Dahlin 2008-12-08 22:44:06 UTC
What release was this reported against that sysvinit got blamed?

I'll look at an upstart equivalent for this.

Comment 3 Bill Nottingham 2008-12-09 15:02:24 UTC
What release? RHEL 4. :)

This is a 'sometime before F11' bug. It might not even need done in upstart; will do some more testing.

Comment 4 Bill Nottingham 2008-12-09 15:25:03 UTC
In fact, upstart's doing the right thing, we're just not handling it right in /etc/init.d/halt.

Comment 6 Bill Nottingham 2009-03-16 17:10:19 UTC
*** Bug 346261 has been marked as a duplicate of this bug. ***

Comment 7 Fedora Update System 2009-04-02 18:04:49 UTC
initscripts-8.86.1-1 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/initscripts-8.86.1-1

Comment 8 Fedora Update System 2009-04-03 04:16:31 UTC
initscripts-8.86.2-1 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/initscripts-8.86.2-1

Comment 9 Fedora Update System 2009-04-22 20:23:00 UTC
initscripts-8.86.3-1 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.