NetBSD-Users archive

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

Re: How can I stop a script running as "deamon" from rc.d?

On 26.12.2010 14:29, hans dinsen-hansen wrote:
> Dear list
> I am running amd64 rel 5.1 (binary, GENERIC kernel) on my laptop.
> My wireless network access point removes my connection if there are
> no requests for a certain amount of time.
> To show that I'm still alive, I've cooked up a tiny script which sends
> a single ping to the nameserver once a minute.  The address is taken
> from resolv.conf.
> I prefer to start the script (called /usr/local/sbin/keepalive) from
> rc.conf just like wpa_supplicant and dhclient.
> The script starts and functions nicely with command_args='&' in
> /etc/rc.d/keepalive.  However, if I stop it, with the command:
>       /etc/rc.d/keepalive stop
> I get the question
>       keepalive not running?
> probably because ps says, "/bin/sh /usr/local/sbin/keepalive" is the
> command which runs the script.
> How do I teach my rc.d/keepalive script to find the right program
> to kill?

Usually, the program should write a PID file (under /var/run) that will
contain the PID of the main program that should receive the signal.

Depending on the application, you either pass an argument to it to
specify the pidfile, the path is hardcoded in the binary, or you use a
third party tool to query for the PID (ugly).

See rc.subr(8), look for pid.

Jean-Yves Migeon

Home | Main Index | Thread Index | Old Index