diff --git a/iceoryx_hoofs/source/posix_wrapper/named_pipe.cpp b/iceoryx_hoofs/source/posix_wrapper/named_pipe.cpp index 3a807e4247..47ae7d721f 100644 --- a/iceoryx_hoofs/source/posix_wrapper/named_pipe.cpp +++ b/iceoryx_hoofs/source/posix_wrapper/named_pipe.cpp @@ -184,17 +184,13 @@ cxx::expected NamedPipe::isOutdated() noexcept cxx::expected NamedPipe::unlinkIfExists(const IpcChannelName_t& name) noexcept { - constexpr int ERROR_CODE = -1; - auto unlinkCall = posixCall(iox_shm_unlink)(convertName(NAMED_PIPE_PREFIX, name).c_str()) - .failureReturnValue(ERROR_CODE) - .ignoreErrnos(ENOENT) - .evaluate(); - if (!unlinkCall.has_error()) + auto result = SharedMemory::unlinkIfExist(name); + if (result.has_error()) { - return cxx::success(unlinkCall->errnum != ENOENT); + return cxx::error(IpcChannelError::INTERNAL_LOGIC_ERROR); } - return cxx::error(IpcChannelError::INTERNAL_LOGIC_ERROR); + return cxx::success(*result); } cxx::expected NamedPipe::trySend(const std::string& message) const noexcept