{"id":19922678,"url":"https://github.com/soundux/guardpp","last_synced_at":"2026-05-13T17:35:00.730Z","repository":{"id":103639792,"uuid":"371846699","full_name":"Soundux/guardpp","owner":"Soundux","description":"💂 A cross-platform C++17 library that can restrict your application to a single instance","archived":false,"fork":false,"pushed_at":"2022-05-19T16:02:11.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-12T00:13:36.166Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Soundux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-29T00:25:02.000Z","updated_at":"2024-09-05T19:26:54.000Z","dependencies_parsed_at":"2023-05-24T04:15:51.504Z","dependency_job_id":null,"html_url":"https://github.com/Soundux/guardpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soundux%2Fguardpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soundux%2Fguardpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soundux%2Fguardpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soundux%2Fguardpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Soundux","download_url":"https://codeload.github.com/Soundux/guardpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241348358,"owners_count":19948164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T22:11:52.048Z","updated_at":"2026-05-13T17:35:00.686Z","avatar_url":"https://github.com/Soundux.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003ch1 align=\"center\"\u003e 💂 guardpp \u003c/h1\u003e\n\u003cp align=\"center\"\u003e\nA C++17 library for single-instance applications\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/Soundux/guardpp/actions\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/workflow/status/Soundux/guardpp/Test%20on%20Linux?label=Linux%20Build\u0026style=flat-square\" alt=\"Linux Build\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/Soundux/guardpp/actions\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/workflow/status/Soundux/guardpp/Test%20on%20Windows?label=Windows%20Build\u0026style=flat-square\" alt=\"Windows Build\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/Soundux/guardpp/blob/master/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/Soundux/guardpp.svg?style=flat-square\" alt=\"License\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## ⚙️ Configuration\n### Tests\n```cmake\nset(guardpp_tests OFF)\n```\n\u003e If set to `ON`, guardpp will build a test executable.\n\n\n## 📎 Installation\n- FetchContent\n    ```cmake\n    include(FetchContent)\n    FetchContent_Declare(lockpp GIT_REPOSITORY \"https://github.com/Soundux/guardpp\")\n\n    FetchContent_MakeAvailable(guardpp)\n    target_link_libraries(\u003cYourLibrary\u003e guardpp)\n    ```\n- Git Submodule\n    ```bash\n    git submodule add \"https://github.com/Soundux/guardpp\"\n    ```\n    ```cmake\n    # Somewhere in your CMakeLists.txt\n    add_subdirectory(\"\u003cpath_to_guardpp\u003e\")\n    target_link_libraries(\u003cYourLibrary\u003e guardpp)\n    ```\n\n## 📔 Usage\n\n### Example\n```cpp\n#include \u003cguard.hpp\u003e\n#include \u003ciostream\u003e\n\nint main()\n{\n    guardpp::guard instance_guard(\"guardpp\");\n\n    auto other_instance = instance_guard.other_instance();\n    \n    if (other_instance)\n    {\n        if (other_instance.value())\n        {\n            std::cout \u003c\u003c \"Another instance is running!\" \u003c\u003c std::endl;\n        }\n        else\n        {\n            std::cout \u003c\u003c \"No other instance is running!\" \u003c\u003c std::endl;\n        }\n    }\n    else\n    {\n        std::cout \u003c\u003c other_instance.error() \u003c\u003c std::endl;\n    }\n\n    // You can also take-over an existing lock by calling instance_guard.reset(); \n}\n```\n\n## 📚 Dependencies\n\n- [`expected`](https://github.com/TartanLlama/expected)\n- [`tiny-process-library`](https://gitlab.com/eidheim/tiny-process-library) _(For tests only!)_\n\n## ℹ️ Remarks\n\n- `guard::reset()` is unimplemented on Windows. This is because on Windows a mutex can only be deleted by closing all existing handles to the mutex, we can not do this because we can't access the handles created by other processes.¹\n\n- The linux implementation now uses file based locks instead of shared memory / semaphores, because they seem to be more robust.²\n\n\u003e ¹ https://stackoverflow.com/questions/9072570/how-can-i-delete-a-mutex-and-semaphore-in-win32-api  \n\u003e ² http://charette.no-ip.com:81/programming/2010-01-13_PosixSemaphores/index.html","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoundux%2Fguardpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoundux%2Fguardpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoundux%2Fguardpp/lists"}