Files
FEX-Emu--FEX/Source/Tools/FEXServer/PipeScanner.cpp
T
Ryan Houdek 8876047875 FEXServer: Fixes background startup
The problem here is that the pipe we used for telling FEXInterpreter
that the FEXServer is ready to accept connections was inherited by
erofsfuse or squashfuse. So the closing of the pipe from the FEXServer
side would leave a reference open in squashfuse or erofsfuse.

Fix this by setting FD_CLOEXEC on the pipe, but also pass the pipe FD
through an argument instead of scanning for all pipes.

Then once we execve the squashfuse/erofsfuse application, the FD isn't
inherited.

Fixes #4329
2025-02-09 23:59:32 -08:00

25 lines
495 B
C++

// SPDX-License-Identifier: MIT
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <vector>
#include <fcntl.h>
namespace PipeScanner {
std::vector<int> IncomingPipes {};
void SetWaitPipe(int FD) {
int flags = fcntl(FD, F_GETFD);
flags |= FD_CLOEXEC;
fcntl(FD, F_SETFD, flags);
IncomingPipes.emplace_back(FD);
}
void ClosePipes() {
for (auto pipe : IncomingPipes) {
close(pipe);
}
IncomingPipes.clear();
}
} // namespace PipeScanner