mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-11 15:00:41 +02:00
Whole-tree reformat
This follows discussions from #3413. Followup commits add clang-format file, script and blame ignore lists.
This commit is contained in:
1 parent
028c220041
commit
2b4ec88dae
447 files changed
+78590
-73070
No files matched your search
@@ -7,44 +7,44 @@
|
||||
#include <vector>
|
||||
|
||||
namespace PipeScanner {
|
||||
std::vector<int> IncomingPipes{};
|
||||
std::vector<int> IncomingPipes {};
|
||||
|
||||
// Scan and store any pipe files.
|
||||
// This will capture all pipe files so needs to be executed early.
|
||||
// This ensures we find any pipe files from execve for waiting FEXInterpreters.
|
||||
void ScanForPipes() {
|
||||
DIR *fd = opendir("/proc/self/fd");
|
||||
if (fd) {
|
||||
struct dirent *dir{};
|
||||
do {
|
||||
dir = readdir(fd);
|
||||
if (dir) {
|
||||
char *end{};
|
||||
int open_fd = std::strtol(dir->d_name, &end, 8);
|
||||
if (end != dir->d_name) {
|
||||
struct stat stat{};
|
||||
int result = fstat(open_fd, &stat);
|
||||
if (result == -1) {
|
||||
continue;
|
||||
}
|
||||
if (stat.st_mode & S_IFIFO) {
|
||||
// Close any incoming pipes
|
||||
IncomingPipes.emplace_back(open_fd);
|
||||
}
|
||||
// Scan and store any pipe files.
|
||||
// This will capture all pipe files so needs to be executed early.
|
||||
// This ensures we find any pipe files from execve for waiting FEXInterpreters.
|
||||
void ScanForPipes() {
|
||||
DIR* fd = opendir("/proc/self/fd");
|
||||
if (fd) {
|
||||
struct dirent* dir {};
|
||||
do {
|
||||
dir = readdir(fd);
|
||||
if (dir) {
|
||||
char* end {};
|
||||
int open_fd = std::strtol(dir->d_name, &end, 8);
|
||||
if (end != dir->d_name) {
|
||||
struct stat stat {};
|
||||
int result = fstat(open_fd, &stat);
|
||||
if (result == -1) {
|
||||
continue;
|
||||
}
|
||||
if (stat.st_mode & S_IFIFO) {
|
||||
// Close any incoming pipes
|
||||
IncomingPipes.emplace_back(open_fd);
|
||||
}
|
||||
}
|
||||
} while (dir);
|
||||
}
|
||||
} while (dir);
|
||||
|
||||
closedir(fd);
|
||||
}
|
||||
}
|
||||
|
||||
void ClosePipes() {
|
||||
for (auto pipe : IncomingPipes) {
|
||||
int Null{0};
|
||||
write(pipe, &Null, sizeof(Null));
|
||||
close(pipe);
|
||||
}
|
||||
IncomingPipes.clear();
|
||||
closedir(fd);
|
||||
}
|
||||
}
|
||||
|
||||
void ClosePipes() {
|
||||
for (auto pipe : IncomingPipes) {
|
||||
int Null {0};
|
||||
write(pipe, &Null, sizeof(Null));
|
||||
close(pipe);
|
||||
}
|
||||
IncomingPipes.clear();
|
||||
}
|
||||
} // namespace PipeScanner
|
||||
Reference in new issue
Block a user