Cross platform way to prevent opening multiple instances of an application

前端 未结 2 1855
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-28 18:00

These questions How to block running two instances of the same program? , How to create a single instance application in C or C++ and Preventing multiple instances of my applica

2条回答
  •  孤街浪徒
    2021-01-28 18:37

    This is not really a complete answer, but look into something like holding a specific file handle for exclusive access. You can use this like a mutex, but with the added benefit that the OS should "clean up" the handle on process termination automatically.

    I cannot speak to if this will work on Linux, but at least on Windows, this should let you achieve the same effect. Hope that helps.

提交回复
热议问题