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 Sun, Dec 26, 2010 at 4:52 PM, Jean-Yves Migeon
<> wrote:
> 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.
Yes, I can see, that a C-program can set a PID file, and when it dies,
the PID-file is removed
automatically.  Can a script set one?  How?
If I could, I probably must remove the PID-file in my trap-part.  If
one stays there after a crash,
i can remove remove it before creating.

> 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