Use file descriptor I/O for process pipes

Use low level non-blocking I/O for process pipe streams. This may fix issues with data not getting through the pipe occasionally.

Related: https://github.com/libsdl-org/SDL/issues/11006
This commit is contained in:
Sam Lantinga
2024-10-04 10:26:34 -07:00
parent f592a35439
commit 00385951a1
3 changed files with 171 additions and 26 deletions

View File

@@ -57,12 +57,7 @@ static bool SetupStream(SDL_Process *process, int fd, const char *mode, const ch
// Set the file descriptor to non-blocking mode
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
FILE *fp = fdopen(fd, mode);
if (!fp) {
return false;
}
SDL_IOStream *io = SDL_IOFromFP(fp, true);
SDL_IOStream *io = SDL_IOFromFD(fd, true);
if (!io) {
return false;
}