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
This commit is contained in:
Joan Bruguera Micó 2024-06-04 13:14:21 +00:00 committed by Brad King
parent efaa9efece
commit ff077af032

View File

@ -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);