How to ensure the execution of only one copy of the application?

Possible duplicate:
Preventing multiple process instances on Linux

I have a multi-threaded application that can be run as a deamon process or once with input parameters.

I want to make sure that if the application is launched as a deception process, the user is not allowed to start it again.

EDIT: After you all suggested going to the herds, I tried it and put it on the server. I know that there is a strange problem, when the servers bounce, they delete all the files, including the lock file :( How now?

+3
source share
3 answers

- ( unix "private") , , , . , ​​ filedescriptor. ( ?) Filedescriptor. .

+4

. , (, ). , . , .

+3

, .

At the beginning of the script, before calling exe, see if this exe works. If it finds that it is still running, the new process does not start.

+2
source

Source: https://habr.com/ru/post/1690406/


All Articles