From a78cefc65b1de37b293b210e4dec1c9f39d914fb Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 6 Jul 2025 20:35:46 +0200 Subject: Add better single instance detection (use rpc fifo file existence with unlink to detect process instead of pidof gsr-ui) --- src/Rpc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Rpc.cpp') diff --git a/src/Rpc.cpp b/src/Rpc.cpp index 3eec98d..803a4dc 100644 --- a/src/Rpc.cpp +++ b/src/Rpc.cpp @@ -32,7 +32,7 @@ namespace gsr { fclose(file); if(!fifo_filepath.empty()) - remove(fifo_filepath.c_str()); + unlink(fifo_filepath.c_str()); } bool Rpc::create(const char *name) { @@ -44,15 +44,16 @@ namespace gsr { char fifo_filepath_tmp[PATH_MAX]; get_runtime_filepath(fifo_filepath_tmp, sizeof(fifo_filepath_tmp), name); fifo_filepath = fifo_filepath_tmp; - remove(fifo_filepath.c_str()); + unlink(fifo_filepath.c_str()); if(mkfifo(fifo_filepath.c_str(), 0600) != 0) { fprintf(stderr, "Error: mkfifo failed, error: %s, %s\n", strerror(errno), fifo_filepath.c_str()); + fifo_filepath.clear(); return false; } if(!open_filepath(fifo_filepath.c_str())) { - remove(fifo_filepath.c_str()); + unlink(fifo_filepath.c_str()); fifo_filepath.clear(); return false; } -- cgit v1.2.3-70-g09d2