I always get the feeling that there are always problems involved with lockfiles. I can think of a 'permission denied' when creating one. I can think of a situation that the instance died unexpectedly. And what if different users run the same program, can they remove eachother lockfiles if necessary ?
Anyway, it would be very nice to have this locking mechanism based on PIDs and the COMMANDs that were used!