================ @@ -71,6 +101,18 @@ ListeningSocket::ListeningSocket(ListeningSocket &&LS) Expected<ListeningSocket> ListeningSocket::createUnix(StringRef SocketPath, int MaxBacklog) { + // Identify instances where the target socket address already exist but hasn't + // been binded to by another program. If there is already a file (of any type) + // at the specified path, ::bind() will fail with an error + if (llvm::sys::fs::exists(SocketPath)) { + Expected<int> MaybeFD = getSocketFD(SocketPath); + if (!MaybeFD) { + return llvm::make_error<StringError>( + std::make_error_code(std::errc::file_exists), + "Cannot create and bind to socket file"); + } ---------------- Bigcheese wrote:
Need to call `::close` on the FD. https://github.com/llvm/llvm-project/pull/67562 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits