mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-19 22:10:52 +00:00
Use non-blocking pipes for process I/O on Windows
Fixes https://github.com/libsdl-org/SDL/issues/10846
This commit is contained in:
@@ -200,6 +200,7 @@ bool SDL_SYS_CreateProcessWithProperties(SDL_Process *process, SDL_PropertiesID
|
||||
HANDLE stdin_pipe[2] = { INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE };
|
||||
HANDLE stdout_pipe[2] = { INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE };
|
||||
HANDLE stderr_pipe[2] = { INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE };
|
||||
DWORD pipe_mode = PIPE_NOWAIT;
|
||||
bool result = false;
|
||||
|
||||
// Keep the malloc() before exec() so that an OOM won't run a process at all
|
||||
@@ -263,6 +264,10 @@ bool SDL_SYS_CreateProcessWithProperties(SDL_Process *process, SDL_PropertiesID
|
||||
stdin_pipe[WRITE_END] = INVALID_HANDLE_VALUE;
|
||||
goto done;
|
||||
}
|
||||
if (!SetNamedPipeHandleState(stdin_pipe[WRITE_END], &pipe_mode, NULL, NULL)) {
|
||||
WIN_SetError("SetNamedPipeHandleState()");
|
||||
goto done;
|
||||
}
|
||||
if (!SetHandleInformation(stdin_pipe[WRITE_END], HANDLE_FLAG_INHERIT, 0) ) {
|
||||
WIN_SetError("SetHandleInformation()");
|
||||
goto done;
|
||||
@@ -296,6 +301,10 @@ bool SDL_SYS_CreateProcessWithProperties(SDL_Process *process, SDL_PropertiesID
|
||||
stdout_pipe[WRITE_END] = INVALID_HANDLE_VALUE;
|
||||
goto done;
|
||||
}
|
||||
if (!SetNamedPipeHandleState(stdout_pipe[READ_END], &pipe_mode, NULL, NULL)) {
|
||||
WIN_SetError("SetNamedPipeHandleState()");
|
||||
goto done;
|
||||
}
|
||||
if (!SetHandleInformation(stdout_pipe[READ_END], HANDLE_FLAG_INHERIT, 0) ) {
|
||||
WIN_SetError("SetHandleInformation()");
|
||||
goto done;
|
||||
@@ -338,6 +347,10 @@ bool SDL_SYS_CreateProcessWithProperties(SDL_Process *process, SDL_PropertiesID
|
||||
stderr_pipe[WRITE_END] = INVALID_HANDLE_VALUE;
|
||||
goto done;
|
||||
}
|
||||
if (!SetNamedPipeHandleState(stderr_pipe[READ_END], &pipe_mode, NULL, NULL)) {
|
||||
WIN_SetError("SetNamedPipeHandleState()");
|
||||
goto done;
|
||||
}
|
||||
if (!SetHandleInformation(stderr_pipe[READ_END], HANDLE_FLAG_INHERIT, 0) ) {
|
||||
WIN_SetError("SetHandleInformation()");
|
||||
goto done;
|
||||
|
||||
Reference in New Issue
Block a user