Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   preventing execution of same executable (http://www.go4expert.com/forums/preventing-execution-executable-t27958/)

priyatendulkar 6Mar2012 11:26

preventing execution of same executable
 
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

xpi0t0s 7Mar2012 17:58

Re: preventing execution of same executable
 
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.

priyatendulkar 7Mar2012 19:04

Re: preventing execution of same executable
 
k..
Thanx a lot for the response


All times are GMT +5.5. The time now is 19:56.