I do not want two instances of my program running at the same time..
If a second instance of the program is then run...:
1) If there is no lock file already (then it is really the first instance) it will create it and carrying out some processing.
2) However if a instance of the lock file already exists the second instance of the program will try to delete it as the first instance of the program holds an exclusive lock the second instance will raise an error which i'll handle in my code. (the second instance of the program not run and end gracefully).
How do I do this..? or is there a better way...?