in reply to atomic operations

I don't think there is any 100% safe way of doing this for an arbitrary process, but in practice it's probably fairly easy to get most of the way there. Some suggestions...

Most systems I've used _seemed_ to avoid reusing a PID at least for a little while. If this is true and your find/kill sequence is short enough, this should get you 99.99% there.

If you have root priviledge and the process you are trying to kill is owned by a non-root user, you could setuid to the user and then perform the kill. Of course this won't help if the same user gets the reused PID quickly enough.

Replies are listed 'Best First'.
Re^2: atomic operations
by Improv (Pilgrim) on Jul 12, 2004 at 20:14 UTC
    Note that on OpenBSD and Linuces that have the "pid randomization patch" applied, they could, in theory, reuse a pid as soon as the old process that used it goes away. This is because they don't cycle through pids, they just randomly pick an unused one when the old goes away. However, collisions relating to this are bound to be quite rare.