MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / ExecAndWaitForResponseRedirect

Function ExecAndWaitForResponseRedirect

Source/Tools/FEXRootFSFetcher/Main.cpp:132–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132int32_t ExecAndWaitForResponseRedirect(const char* path, char* const* args, int stdoutRedirect = -2, int stderrRedirect = -2) {
133 pid_t pid = fork();
134 if (pid == 0) {
135 if (stdoutRedirect == -1) {
136 close(STDOUT_FILENO);
137 } else if (stdoutRedirect == -2) {
138 // Do nothing
139 } else {
140 if (stdoutRedirect != STDOUT_FILENO) {
141 close(STDOUT_FILENO);
142 }
143 dup2(stdoutRedirect, STDOUT_FILENO);
144 }
145 if (stderrRedirect == -1) {
146 close(STDERR_FILENO);
147 } else if (stderrRedirect == -2) {
148 // Do nothing
149 } else {
150 if (stderrRedirect != STDOUT_FILENO) {
151 close(STDERR_FILENO);
152 }
153 dup2(stderrRedirect, STDERR_FILENO);
154 }
155 execvp(path, args);
156 _exit(-1);
157 } else {
158 int32_t Status {};
159 while (waitpid(pid, &Status, 0) == -1 && errno == EINTR)
160 ;
161 if (WIFEXITED(Status)) {
162 return (int8_t)WEXITSTATUS(Status);
163 }
164 }
165
166 return -1;
167}
168
169std::string ExecAndWaitForResponseText(const char* path, char* const* args) {
170 int fd[2];

Callers 6

CheckCurlFunction · 0.85
CheckSquashfuseFunction · 0.85
CheckUnsquashfsFunction · 0.85
CheckZenityFunction · 0.85
CheckEroFSFuseFunction · 0.85
CheckEroFSFsckFunction · 0.85

Calls 1

closeFunction · 0.85

Tested by

no test coverage detected