This kills every process with a handle to file /foo/bar (in bash):
lsof /foo/bar 2>&1 | grep "/foo/bar" | sed "s/ */\\t/g" | cut -f 2 | while read PID; do kill $PID; done
This does not seem like such an uncommon task that there wouldn't be an easier solution, so I'm wondering if there's something like
killall or a switch to
kill that I've missed which does the same.