in src/UnixForkHandler.cpp [78:108]
static void childHandler() {
if (globalStderrPipeFd[1] == -1) return;
stdoutPipeFd = globalStdoutPipeFd[1];
stderrPipeFd = globalStderrPipeFd[1];
if (stdoutPipeFd == -1 || stderrPipeFd == -1) {
return;
}
close(globalStdoutPipeFd[0]);
close(globalStderrPipeFd[0]);
atexit([] {
close(stdoutPipeFd);
close(stderrPipeFd);
});
if (rpiService != nullptr) {
rpiService->setChildProcessState();
}
mainOutputHandler = [](const char* buf, int size, OutputType type) {
while (size > 0) {
int cnt;
if (type == STDOUT) {
cnt = write(stdoutPipeFd, buf, size);
} else {
cnt = write(stderrPipeFd, buf, size);
}
if (cnt <= 0) {
break;
}
size -= cnt;
}
};
}