How do I check whether the program run ?

F

Ferman

Hi,

I wrote a program. I want it to check whether the program still run. If the
program run, then it doesn't run second instance, finish new instance.

How do I check whether the program still run ?
 
S

Skippy

I wrote a program. I want it to check whether the program still run. If
the
program run, then it doesn't run second instance, finish new instance.

How do I check whether the program still run ?

you have a few possibilities:
- create a file when starting, delete it when closing
- open a socket on a port

then check if the file exists of the port is opened, if so, don't start the
second instance
 
R

Robert Olofsson

Ferman ([email protected]) wrote:
: Hi,

: I wrote a program. I want it to check whether the program still run. If the
: program run, then it doesn't run second instance, finish new instance.

: How do I check whether the program still run ?

If you told us more about what your program does, what OS you run on
and you could get more help.

- Let your program create a file with delete on exit.
File may still exist if you program gets killed.
Other programs may create file.

- Let your program listen to a socket
Other programs may open socket.

- check the process listing (with ps (unix) or task manager (windows))
manual inspection.

/robo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top