From ff077af0320611abf024d2c4d05baecb71de705c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= Date: Tue, 4 Jun 2024 13:14:21 +0000 Subject: ctest: Set close-on-exec for jobserver FIFO Set the close-on-exec flag to prevent the jobserver FIFO file descriptor from leaking to subprocesses spawned by `ctest`. This leak is usually harmless, but can cause `make test -jN` to hang at the end of the build if a test leaves a background process running with the jobserver FIFO file descriptor open. Fixes: #26027 --- Source/CTest/cmUVJobServerClient.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/CTest/cmUVJobServerClient.cxx b/Source/CTest/cmUVJobServerClient.cxx index d7d76c9..055b29b 100644 --- a/Source/CTest/cmUVJobServerClient.cxx +++ b/Source/CTest/cmUVJobServerClient.cxx @@ -306,6 +306,10 @@ void ImplPosix::ConnectFIFO(const char* path) if (fd < 0) { return; } + if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { + close(fd); + return; + } cm::uv_pipe_ptr connFIFO; connFIFO.init(this->Loop, 0, this); -- cgit v0.12