Results 1 to 4 of 4
Hello Guys,
I have a problem,I coded a gtk program(Using C) which i want it to run only in one process.i.e let say i started the program ./helloworld and leave ...
- 06-20-2006 #1Just Joined!
- Join Date
- Jun 2006
- Location
- Bangalore , India
- Posts
- 27
One instance of a program
Hello Guys,
I have a problem,I coded a gtk program(Using C) which i want it to run only in one process.i.e let say i started the program ./helloworld and leave it running. and i run ./helloworld in another terminal it has to say the program is already running .So anybody haev a clue how to do this.... If you do please help me out i need it very urgently.
thank YOU
- 06-20-2006 #2
You can create a temporary file and delete it on exit, or you can check the process list. I'm positive that there's more and better ways to do it, though. Just a few ideas.
Flies of a particular kind, i.e. time-flies, are fond of an arrow.
Registered Linux User #408794
- 06-20-2006 #3The way gpm, dhcpcd, syslog, and probably a few others, do this is by creating a file in /var/run called program.pid, such as gpm.pid, within this file contains the pid of the program being run, but on it's own the existence of the file indicates that one existence of the program is already being run, and that gets removed when the program ends.
Originally Posted by Javasnob
- 06-21-2006 #4Just Joined!
- Join Date
- Jun 2006
- Location
- Bangalore , India
- Posts
- 27
Another small doubt
HI
Thanks a lot for you response guys it was very helpful,But i have a small doubt.Is it possible for a user to delete the file i created in /var/run/ while the program is running ,because if it is possible what's the use he will delete that file and runs another instance of that program........... what should i do?


Reply With Quote
