#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0

    Allow only one execution at a time


    Hi all,

    I am writing a license server application, and I want to prevent multiple execution of the server program on a PC.

    Is there a way to allow only one server process to run on a PC by coding?

    Thank you :thumbs:

    Code: C Language
    OS : Linux
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,363
    Rep Power
    1870
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0
    Dear salem,

    Thank you for the link :)

    It helps!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0
    Dear salem,

    Seems like O_EXCL with open() works when starting a daemon, but how could I keep track if the lock file has been delete or recreated ?

    For example, if daemon creates a file /var/tmp/lock, user could just delete it after starting first daemon process, then the second daemon process will be able to start.

    So, I think I will need to keep track if lock file has been deleted or recreated.

    Thanks

IMN logo majestic logo threadwatch logo seochat tools logo