Results 1 to 2 of 2
hello
OS: CENTOS 5
How to detect/prevent running the multiple instance of same application, in c++ code.
My applicaion is written in c++. and compile using the g++ version 4.1.2.
...
- 06-26-2008 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 15
How to prevent/detect running multiple instance of same application/dameon
hello
OS: CENTOS 5
How to detect/prevent running the multiple instance of same application, in c++ code.
My applicaion is written in c++. and compile using the g++ version 4.1.2.
Thanks in advance.
Ritesh
- 06-26-2008 #2
In your program, create a file in the /tmp directory. Use advisory locking to lock, say, the first byte in the file. If the lock succeeds, then the application should continue running. If it fails, then the application should exit.
For information on advisory locking, do this at the command line:
If man pages are not installed on your system, google this:Code:man fcntl
Hope this helps.Code:linux man fcntl
--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote