LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-19-2006, 03:01 AM   #1
manishpatidar
LQ Newbie
 
Registered: Dec 2005
Posts: 8

Rep: Reputation: 0
Question how to make singleton application in C++


hi,
i m trying to make singleton application so only one instace can run at a time. i tried to used executable name and process id but any one can change executable name.
i dont want to use any port because if that port is used by any other application then application will not run.
Do u have any idea how i can make my application as single application (c++) ?

Manish
 
Old 05-30-2006, 07:27 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,989

Rep: Reputation: 5680Reputation: 5680Reputation: 5680Reputation: 5680Reputation: 5680Reputation: 5680Reputation: 5680Reputation: 5680Reputation: 5680Reputation: 5680Reputation: 5680
If you store process ID in a file in some directory and have the process run other then a regular user then you should be able to make a application only run once. The directory will be owned by the process user with r/w permissions only will read permissions for everyone else. This would be good for a process that is started at boot.

Another idea not as complex and similar to the first would be to have the directory that stores the process ID file be hidden somewhere obscure. The process looks for the file at boot and if it exists quit with a already running message. A gracefull shutdown would delete the file. If the program crashes then you would have a problem.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
c++: Problems with a singleton (as a so) eantoranz Programming 11 02-20-2006 10:38 AM
Triple check singleton pattern dmail Programming 0 12-19-2005 09:56 AM
How to make it a default application? jethind Linux - Newbie 8 11-17-2005 07:36 AM
singleton pattern in C++? Thinking Programming 7 11-13-2005 08:45 PM
make application default reaky Linux - Software 5 05-24-2004 12:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration