Recent

Author Topic: Running single instance of a program  (Read 4764 times)

Awesome Programmer

  • Sr. Member
  • ****
  • Posts: 451
  • Programming is FUN only when it works :)
    • Cool Technology
Running single instance of a program
« on: April 06, 2016, 04:19:43 pm »
I wrote a program using latest Lazarus and FPC on a Linux System. And I forgot about accidentally running multiple copies of this program. Now, the software is already released. So, what are my options when it comes to preventing multiple copies or forcing single copy of my program? I don't want to have to mess around with my project files or update my code to force single copy. Does Linux System have a feature that I can use to force single copy of any program running system wide? Any help or hint will be much appreciated. Thank you.
« Last Edit: April 06, 2016, 04:23:29 pm by reltek »

CM630

  • Hero Member
  • *****
  • Posts: 1091
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Running single instance of a program
« Reply #1 on: April 06, 2016, 05:04:50 pm »
I use http://wiki.freepascal.org/UniqueInstance but I have no idea if it is system independent.
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

Awesome Programmer

  • Sr. Member
  • ****
  • Posts: 451
  • Programming is FUN only when it works :)
    • Cool Technology
Re: Running single instance of a program
« Reply #2 on: April 11, 2016, 08:03:25 pm »
Thanks. I realized I had forgotten about the UniqueInstance.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Running single instance of a program
« Reply #3 on: April 12, 2016, 02:04:03 am »
The feature is also integrated in TCustomApplication in FPC 3.1.1.
See
  http://bugs.freepascal.org/view.php?id=7992
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

lucky62

  • Newbie
  • Posts: 1
Re: Running single instance of a program
« Reply #4 on: May 01, 2016, 05:46:12 am »
I found this simple solution for windows using mutex:
http://forum.codecall.net/topic/61751-prevent-multiple-instance-of-a-program-using-mutex/

It is working fine but windows only. There is any similar solution for Linux? (not UniqueInstance)

 

TinyPortal © 2005-2018