How to block running two instances of the same program?

后端 未结 8 1264
暗喜
暗喜 2020-12-01 05:23

I need to make sure that user can run only one instance of my program at a time.
Which means, that I have to check programatically, whether the same program is already r

8条回答
  •  一整个雨季
    2020-12-01 06:19

    It is very un-unix to prohibit multiple instances of a program to run.

    If the program is, say, a network daemon, it doesn't need to actively prohibit multiple instances--only the first instance gets to listen to the socket, so subsequent instances bomb out automatically. If it is, say, an RDBMS, it doesn't need to actively prohibit multiple instances--only the first instance gets to open and lock the files. etc.

提交回复
热议问题