From b254f75968e1a5692fa872fcfda5eaa1a0ed561d Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Wed, 16 Oct 2024 09:49:55 +0200 Subject: safer path from handle (#195) * remove PathFromHandle that throws to give better context on failures --- src/zencore/thread.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/zencore/thread.cpp') diff --git a/src/zencore/thread.cpp b/src/zencore/thread.cpp index 394197b8e..ca3759fbf 100644 --- a/src/zencore/thread.cpp +++ b/src/zencore/thread.cpp @@ -348,8 +348,16 @@ NamedEvent::Close() if (flock(Fd, LOCK_EX | LOCK_NB) == 0) { - std::filesystem::path Name = PathFromHandle((void*)(intptr_t(Fd))); - unlink(Name.c_str()); + std::error_code Ec; + std::filesystem::path Name = PathFromHandle((void*)(intptr_t(Fd)), Ec); + if (Ec) + { + ZEN_WARN("Error reported on get file path from handle {} for named event unlink operation, reason '{}'", Fd, Ec.message()); + } + else + { + unlink(Name.c_str()); + } flock(Fd, LOCK_UN | LOCK_NB); close(Fd); -- cgit v1.2.3