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 18:16, hans dinsen-hansen wrote:
> 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?

Yes, when the program is run in background mode (with &), use echo $! to
get PID of backgrounded program:

$ ./your_program &
$ echo $! > /var/run/

> 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.

Just override the pidfile.

Jean-Yves Migeon

Home | Main Index | Thread Index | Old Index