[prev in list] [next in list] [prev in thread] [next in thread] 

List:       netbsd-users
Subject:    Re: How can I stop a script running as "deamon" from rc.d?
From:       Jean-Yves Migeon <jeanyves.migeon () free ! fr>
Date:       2010-12-26 17:31:51
Message-ID: 4D177C07.8030405 () free ! fr
[Download RAW message or body]

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/your_program.pid

> 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
jeanyves.migeon@free.fr
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic