mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-07 00:00:17 +02:00
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
25 lines
495 B
C++
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
|