preventing execution of same executable

Go4Expert Member
6Mar2012,11:26   #1
priyatendulkar's Avatar
Hi ,

I have an executable say a.out.

My requirement is that ..At a time only single instance of a.out be executed

Is that possible in linux
Mentor
7Mar2012,17:58   #2
xpi0t0s's Avatar
I don't think you can prevent the OS launching a second copy of the executable but you can make them detect each other. For example one way is to create a file lock when the executable starts, so if a second instance is launched, it would try to lock that file, fail, deduce from that that there is already someone else running and exit.
Go4Expert Member
7Mar2012,19:04   #3
priyatendulkar's Avatar
k..
Thanx a lot for the response