You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int main(){
const char* args[] {"clang++", "--help", nullptr};
SDL_Process* p = SDL_CreateProcess(args, true);
SDL_WaitProcess(p, true, nullptr);
SDL_DestroyProcess(p);
}
Side note, Using SDL_ReadIO and SDL_LoadFile_IO on p.stream before and after flushing/closing doesn't give the output that was written to the file. I don't know if this is intended or not.
Your code also blocks on Linux.
clang's help is very long and will fill the pipe buffer (64kiB on Linux).
What's happening is that the kernel suspends the process (because write(2) is a blocking write) until the pipe buffer is drained.
Thanks for the info. I guess it should be mentioned in the SDL_WaitProcess docs somewhere. I thought what I had to do was, SDL_WaitProcess() then do a SDL_ReadProcess() and not the other way around.
The process subsystem is relatively very prone to a deadlock. My code above would lock when clang would read from stdin (close stdin of the subprocess after startup to avoid this. I have to check myself now what would happen if a subprocess opens /dev/tty after having closed stdin)
You need to code very careful to avoid this.
Side note, Using SDL_ReadIO and SDL_LoadFile_IO on p.stream before and after flushing/closing doesn't give the output that was written to the file. I don't know if this is intended or not.
OS : Windows 10.
The text was updated successfully, but these errors were encountered: