On Sun, Dec 13, 2020 at 08:27:24PM +0100, Harald Dunkel wrote:
At least OpenBSD is not alone with this problem. On Debian there
is a tool "/bin/pidof", trying to guess the pid of a daemon to kill
by looking at the process list as well.

Some dude from Google came up with a good solution (for Linux of
course). If you open a /proc/[pid] directory this PID cannot be recycled
unless you close the fd. Hence you can do this:

        1. Read /var/run/foobard.lock and get PID
        2. Open /proc/[pid]
        3. Check that PID is in fact belongs to an instance of foobard
        4. kill() it

Easy.

Reply via email to