[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bug? with file-rc



Jonathan P Tomer wrote:
  >dpkg -l file-rc
  >ii  file-rc         0.4.3          Alternative one-configfile boot mechanism
  >
  >i don't know if this is supposed to be the case or not, but contrary to
  >file-rc's documentation, scripts are not run in reverse order for shutting
  >down. is this a debian-specific thing or merely a bug? are the etc/rcN.d/Kmm
      >*
  >scripts run in descending order when file-rc is not used?

This is from the Policy manual:
   The names of the links all have the form Smm/script or Kmm/script where
   mm is a two-digit number and script is the name of the script (this
   should be the same as the name of the actual script in /etc/init.d.
   When init changes runlevel first the targets of the links whose names
   starting with a K are executed, each with the single argument stop,
   followed by the scripts responsible for killing services and the S link
   for starting services upon entering the runlevel.

   For example, if we are changing from runlevel 2 to runlevel 3, init
   will first execute all of the K prefixed scripts it finds in /etc/rc3.d,
   and then all of the S prefixed scripts. The links starting with K will
   cause the referred-to file to be executed with an argument of stop, and
   the S links with an argument of start.

   The two-digit number mm is used to decide which order to start and stop
   things in -- low-numbered links have their scripts run first. For example,
   the K20 scripts will be executed before the K30 scripts. 

So the way it should work is:
  init sends SIGTERM to everything not listed in /etc/inittab for the new
    runlevel, and
  init runs `/etc/init.d/rc new_run_level'
      this runs the K script for everything in the new runlevel
      then it runs the S script for everything in the new runlevel

So the rationale of the K scripts is not to kill things from the previous
runlevel but from the new one.  The results of this policy are seen
in the layout of /etc/rc?.d: the K scripts are in runlevels 0, 1 and 6,
whereas the S levels are in 2, 3, 4 and 5.  Therefore the file-rc
documentation is wrong, but its behaviour is right.


It seems rather clumsy, though.  Why was this scheme chosen, instead of
one where the K scripts are run for the previous runlevel?  The current 
scheme works fine for shutting down and going to single user mode, but
is very clumsy for an administrator who wants to assign meanings to
run-levels 2 to 5 (which Debian does not currently do).

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
               PGP key from public servers; key ID 32B8FAA1
                 ========================================
     "Jesus saith unto him, I am the way, the truth, and the
      life; no man cometh unto the Father, but by me."      
                                John 14:6 



Reply to: