Date: Tue, 15 Jun 1999 18:54:06 +0800 From: Gong Wei <ccegongw@nus.edu.sg> To: "'aphor@ripco.NOSPAM.com'" <aphor@ripco.NOSPAM.com> Cc: 'Matt Behrens' <matt@zigg.com>, 'Alan Edmonds' <alan.edmonds@sterling.com>, "'freebsd-questions@freebsd.org'" <freebsd-questions@freebsd.org> Subject: RE: *BSD init scripts Message-ID: <762388C091FAD01180FF00A024621378E8EF19@exs01.ex.nus.edu.sg>
next in thread | raw e-mail | index | archive | help
Hi, Thanks for the reply! I just did a "kill -INT 1" and found that /etc/rc.shutdown has been called! This solves my problem ... :-) So, it seems that "reboot" or "shutdown -r now" or "shutdown -h now" doesn't send an "INT" signal to init. At least my observation is that none of the three mentioned commands triggered the /etc/rc.shutdown script. Thanks to all replied and hopefully this email could be useful for someone out there ... -----Original Message----- From: Jeremy McMillan [mailto:aphor@ripco.NOSPAM.com] Sent: Tuesday, June 15, 1999 7:34 AM To: Gong Wei Subject: Re: *BSD init scripts Does init log signals it recieves? From INIT(8): > > Init will terminate multi-user operations and resume single-user mode if > sent a terminate (TERM) signal, for example, ``kill -TERM 1''. If there > are processes outstanding that are deadlocked (because of hardware or > software failure), init will not wait for them all to die (which might > take forever), but will time out after 30 seconds and print a warning > message. > > Init will cease creating new getty's and allow the system to slowly die > away, if it is sent a terminal stop (TSTP) signal, i.e. ``kill -TSTP > 1''. A later hangup will resume full multi-user operations, or a termi- > nate will start a single user shell. This hook is used by reboot(8) and > halt(8). > > 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. > > 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). > Gong Wei wrote: > > Hi all, > > So far I have received a few replies from the list, first of all thank you > all for your time! > > Probably I didn't phase my question correctly. Here let me try again. > > I am looking for a customizable script that init will call upon shutting > down and/or rebooting, *BEFORE* sending TERM signal to running processes. > > In SysV world(Sorry for this as all along I was using SysV variant like > Linux/Solaris) there is something called runlevel. So rebooting is actually > going to run level 6 whereas shutting down (halt) is going to runlevel 0. > This process will call all K* scripts in the corresponding directory with a > "stop" argument. Then it will send TERM signal (15) to all running process. > > Someone suggested me to change the script to accept one possible argument > "start" and/or "stop" and react accordingly. That is really not an issue at > all, the issue is whether the script will ever be called with a "stop" > argument or not. I know that on 3.2-RELEASE, all /usr/local/etc/rc.d/*.sh > will always be called with a "start" argument upon startup, but what about > shutting down/reboot? > > Someone also suggested to modify the daemon source code to install a signal > handler which is really overkill in this case. In fact what I want to do is > faily simple: > ================================================== > case "$1" in > start) > mv /etc/somefilea /etc/somefileb > somedir/smbd -D > somedir/nmbd -D > ;; > stop) > mv /etc/somefileb /etc/somefileb > kill `cat anotherdir/nmbd.pid` > kill `cat anotherdir/smbd.pid` > ;; > *) > echo "Usage: xxxxx" > exit 1 > esac > ================================ > > I hope I expressed myself clearly this time :-) > > -----Original Message----- > From: Gong Wei [mailto:ccegongw@nus.edu.sg] > Sent: Monday, June 14, 1999 8:35 AM > To: 'freebsd-questions@freebsd.org' > Cc: 'freebsd-stable@freebsd.org' > Subject: *BSD init scripts > > Hi, > > I have a special requirement for starting and shutting down a particular > daemon. For starting up no problem, I can create a file abc.sh in > /usr/local/etc/rc.d. But what about shutting down the daemon? It cannot be > simply killed by -15 or -9. Some custom action must be taken place before > the daemon got killed. > > Is there any way to achieve this? I tried to put in some instructions in > /etc/rc.shutdown, but it seems that this script (rc.shutdown) didn't get > called at all if I use reboot/shutdown -r now/shutdown -h now/halt to stop > the system. > > However, if I press Ctl-Alt-Del this script did get called. > > I am using Release 3.2 on Intel platform, if this matters. > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-stable" in the body of the message -- PLEASE NOTICE: THERE MAY BE NOSPAM IN THE HEADERS WHEN YOU HIT "REPLY"!!! Jeremy McMillan <aphor at ripco.com> | Ask for PGP-2.6.2 or 5.0i Chicago FreeBSD Users Group http://pages.ripco.com/~aphor/ChiFUG.html To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?762388C091FAD01180FF00A024621378E8EF19>