After learning of the ability to run a script (/etc/rc.shutdown) at
shutdown time in FreeBSD 2.2.5, I was somewhat surprised to discover
exactly how and when it is invoked!
My first attempts to run the shutdown script failed dismally. Every
time I did a "shutdown -h ..." or "shutdown -r ...", the system simply
shutdown. No script was run! I looked at the init code and it looked
like it should be run so I simply executed the command "kill -TERM 1"
and, lo and behold, the script ran as I expected it to.
Further investigation of the 'shutdown' program showed that a SIGTERM is
_NOT_ sent to init. It simply invokes the 'reboot' or 'halt' programs,
neither of which send a SIGTERM to init.
Given my habit of using shutdown/reboot/halt to bring a system down, I
am rather curious as to how the designer/coder of this new "feature"
intented it be used. Are we looking at incomplete functionality?
I can get around the problem by renaming shutdown, reboot, and halt to
something else and putting my own shutdown in their place that _DOES_ do
a kill -TERM on init but that seems rather kludgy!