Operating System - HP-UX
1832926 Members
3161 Online
110048 Solutions
New Discussion

Sinlge Instance of the Application

 
Lalit Seth
Frequent Advisor

Sinlge Instance of the Application

Hi,

I am having a C++ Application.

I wanted to make sure that its only one instance is active at a particular time.

Is there any System Call to do the same or other way to acheive the same?

Many Thanks
2 REPLIES 2
Fred Ruffet
Honored Contributor

Re: Sinlge Instance of the Application

I think it's your program that may look for this. When it starts, it should look for another instance. If one running, then exit immediately. That is done by many programs using lock files.
If you want a program to monitor, how would this one know which one to kill ? Or even if it is safe to kill ?

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Steve Steel
Honored Contributor

Re: Sinlge Instance of the Application

Hi


Simple solution most programs use is to make a file like
/tmp/applicationPID containing the process id of this application.

If file exists give a message and exit until either file is manually removed or other copy of application stops.

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)