Bug 34109

Summary: /etc/rc.shutdown isn't run on halt(8)
Product: Base System Reporter: clemensF <ino-e95abb57>
Component: confAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-RELEASE   
Hardware: Any   
OS: Any   

Description clemensF 2002-01-21 11:00:09 UTC
	the documentation of neither init(8) not halt(8) doesn't tell that
/etc/rc.shutdown is only run when the system goes single-user after "kill
-TERM 1" or "init 1", i had to use the source code.  the documentation
(init) states:  "When shutting down the machine, init will try to run the
/etc/rc.shutdown script.  This script can be used to cleanly terminate
specific programs such as innd (the InterNetNews server)."

also, a template is provided in /etc, so i put all the shutdown-stuff in
there.  running this script only on transition to single-user is counter-
intuitive.  /etc/rc.shutdown is the logical place to put shutdown-code, so
it should be used on every shutdown.

Fix: 

use "sh /etc/rc.shutdown" before halting the machine, inform
administrators about the flaw in the documentation.

clemens fischer
Comment 1 Peter Pentchev 2002-01-21 11:53:25 UTC
On Mon, Jan 21, 2002 at 11:28:21AM +0100, clemensF wrote:
> >Number:         34109
> >Category:       conf
> >Synopsis:       /etc/rc.shutdown isn't run on halt(8)
> >Originator:     Tip Chap
> >Release:        FreeBSD 4.3-RELEASE i386
> 
> >Description:
> 
> 	the documentation of neither init(8) not halt(8) doesn't tell that
> /etc/rc.shutdown is only run when the system goes single-user after "kill
> -TERM 1" or "init 1", i had to use the source code.  the documentation
> (init) states:  "When shutting down the machine, init will try to run the
> /etc/rc.shutdown script.  This script can be used to cleanly terminate
> specific programs such as innd (the InterNetNews server)."

Errr.. how exactly did you try to shut your system down?
The /etc/rc.shutdown script is run quite fine if you use the shutdown(8)
utility, which also happens to be referenced in the halt(8) manual page.
Quoting from the halt(8) manual page:

  Normally, the shutdown(8) utility is used when the system needs to be
  halted or restarted, giving users advance warning of their impending doom
  and cleanly terminating specific programs.

Note the 'cleanly terminating specific programs' part :)

G'luck,
Peter

-- 
This sentence no verb.
Comment 2 clemensF 2002-01-21 14:42:39 UTC
> Peter Pentchev:

> Errr.. how exactly did you try to shut your system down?

i do not need the functionality of shutdown(8), so i choose halt(8) to do
the job.

> The /etc/rc.shutdown script is run quite fine if you use the shutdown(8)

i will try shutdown(8), but i'm really not sure i want it.

>   Normally, the shutdown(8) utility is used when the system needs to be
>   halted or restarted, giving users advance warning of their impending doom
>   and cleanly terminating specific programs.
> 
> Note the 'cleanly terminating specific programs' part :)

do you suggest users do guesswork to find out if a clearly defined script
is run or not?  i'd prefer "... and runs /etc/rc.shutdown to cleanly
terminate specific programs."

clemens fischer
Comment 3 Peter Pentchev 2002-01-21 14:56:44 UTC
On Mon, Jan 21, 2002 at 03:42:39PM +0100, clemensF wrote:
> > Peter Pentchev:
> 
> > Errr.. how exactly did you try to shut your system down?
> 
> i do not need the functionality of shutdown(8), so i choose halt(8) to do
> the job.
> 
> > The /etc/rc.shutdown script is run quite fine if you use the shutdown(8)
> 
> i will try shutdown(8), but i'm really not sure i want it.

There is no overhead in a 'shutdown -h now' or 'shutdown -r now'
invocation, while there is a lot to be said about letting the system
shut itself down gracefully.  halt(8) and reboot(8) are there only
as a last resort utilities for really urgent cases.

> >   Normally, the shutdown(8) utility is used when the system needs to be
> >   halted or restarted, giving users advance warning of their impending doom
> >   and cleanly terminating specific programs.
> > 
> > Note the 'cleanly terminating specific programs' part :)
> 
> do you suggest users do guesswork to find out if a clearly defined script
> is run or not?  i'd prefer "... and runs /etc/rc.shutdown to cleanly
> terminate specific programs."

shutdown(8) does not run /etc/rc.shutdown; init(8) does.
All that shutdown(8) does is initiate a system shutdown.

G'luck,
Peter

-- 
What would this sentence be like if it weren't self-referential?
Comment 4 Crist J. Clark freebsd_committer freebsd_triage 2002-01-22 08:01:33 UTC
On Mon, Jan 21, 2002 at 07:00:05AM -0800, Peter Pentchev wrote:
> On Mon, Jan 21, 2002 at 03:42:39PM +0100, clemensF wrote:
> > > Peter Pentchev:

[snip]

> > >   Normally, the shutdown(8) utility is used when the system needs to be
> > >   halted or restarted, giving users advance warning of their impending doom
> > >   and cleanly terminating specific programs.
> > > 
> > > Note the 'cleanly terminating specific programs' part :)
> > 
> > do you suggest users do guesswork to find out if a clearly defined script
> > is run or not?  i'd prefer "... and runs /etc/rc.shutdown to cleanly
> > terminate specific programs."
> 
> shutdown(8) does not run /etc/rc.shutdown; init(8) does.
> All that shutdown(8) does is initiate a system shutdown.

I think the code is all sound. However, the init(8) manpage is not
clear about when /etc/rc.shutdown is run.
-- 
Crist J. Clark                     |     cjclark@alum.mit.edu
                                   |     cjclark@jhu.edu
http://people.freebsd.org/~cjc/    |     cjc@freebsd.org
Comment 5 clemensF 2002-01-22 14:43:47 UTC
i rest my case, and i'm slowly getting used to shutdown(8).  only thing
left would be changing the documentation.

clemens fischer
Comment 6 ru freebsd_committer freebsd_triage 2002-01-24 09:23:22 UTC
On Tue, Jan 22, 2002 at 12:10:01AM -0800, Crist J . Clark wrote:
> The following reply was made to PR conf/34109; it has been noted by GNATS.
> 
> From: "Crist J . Clark" <cjc@freebsd.org>
> To: Peter Pentchev <roam@ringlet.net>
> Cc: bug-followup@freebsd.org
> Subject: Re: conf/34109: /etc/rc.shutdown isn't run on halt(8)
> Date: Tue, 22 Jan 2002 00:01:33 -0800
> 
>  On Mon, Jan 21, 2002 at 07:00:05AM -0800, Peter Pentchev wrote:
>  > On Mon, Jan 21, 2002 at 03:42:39PM +0100, clemensF wrote:
>  > > > Peter Pentchev:
>  
>  [snip]
>  
>  > > >   Normally, the shutdown(8) utility is used when the system needs to be
>  > > >   halted or restarted, giving users advance warning of their impending doom
>  > > >   and cleanly terminating specific programs.
>  > > > 
>  > > > Note the 'cleanly terminating specific programs' part :)
>  > > 
>  > > do you suggest users do guesswork to find out if a clearly defined script
>  > > is run or not?  i'd prefer "... and runs /etc/rc.shutdown to cleanly
>  > > terminate specific programs."
>  > 
>  > shutdown(8) does not run /etc/rc.shutdown; init(8) does.
>  > All that shutdown(8) does is initiate a system shutdown.
>  
>  I think the code is all sound. However, the init(8) manpage is not
>  clear about when /etc/rc.shutdown is run.
>  
I don't see a problem with documentation:

: Init will terminate all possible processes (again, it will not wait for
: deadlocked processes) and reboot the machine if sent the interrupt (INT)
: signal, i.e. ``kill -INT 1''.  This is useful for shutting the machine
                                                    ^^^^^^^^^^^^^^^^^^^^
: down cleanly from inside the kernel or from X when the machine appears to
  ^^^^^
: be hung.
: 
: Init will do the same, except it will halt the machine if sent the user
                                        ^^^^
: defined signal 1 (USR1), or will halt and turn the power off (if hardware
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
: permits) if sent the user defined signal 2 (USR2).
: 
: When shutting down the machine, init will try to run the /etc/rc.shutdown
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: script.  This script can be used to cleanly terminate specific programs
: such as innd (the InterNetNews server).

The best thing we can do is to join the third paragraph with the first.


Cheers,
-- 
Ruslan Ermilov		Oracle Developer/DBA,
ru@sunbay.com		Sunbay Software AG,
ru@FreeBSD.org		FreeBSD committer,
+380.652.512.251	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age
Comment 7 Tom Rhodes freebsd_committer freebsd_triage 2003-01-09 17:13:37 UTC
State Changed
From-To: open->closed

Reading over the documentation, I agree with ru.  Submitter also agrees to 
the final outcome.  Closed.