SDL_ReadProcess(3)
π SDL_ReadProcess(3) β the SDL3 functions girlies know this one
okay so bestie, welcome to SDL_ReadProcess(3) from the SDL3 FUNCTIONS collection. This is the one where you spawn a whole entire process and then justβ¦ read everything it says. Like reading your group chat after you fell asleep at 9pm. β¨
β¨ NAME β¨
SDL_ReadProcess β read all the output from a process. every last byte. no crumbs. π
π SYNOPSIS π
#include <SDL3/SDL_process.h>
void * SDL_ReadProcess(SDL_Process *process, size_t *datasize, int *exitcode);
πΈ DESCRIPTION πΈ
so here's the vibe: if a process was created with I/O enabled, you can use this function to read the output. That's it, that's the job. π
And the way it does it?? This function blocks until the process is complete, capturing all the output, and also handing you back the process exit code. It will simply wait. Patiently. Like a bestie holding your bag at the mall. π«Ά
The data is allocated with a zero byte at the end (null terminated) for convenience. Very thoughtful, very demure. But heads up: that extra byte is not included in the value reported via datasize. So don't go counting it, okay? π
The data should be freed with SDL_free(). Bestie. Free the data. I am begging. π
π FUNCTION PARAMETERS π
processβ the process to read. the main character in question. πdatasizeβ a pointer filled in with the number of bytes read. it may beNULL, so if you don't care, you can just say no. πexitcodeβ a pointer filled in with the process exit code if the process has exited. it also may beNULL. no pressure fr fr.
β RETURN VALUE β
Returns the data, or NULL on failure. And if it's giving NULL?? call SDL_GetError() for more information, because it will absolutely tell you what went wrong. π₯
π¦ THREAD SAFETY π¦
This function is not thread safe. do not send it into the group chat from multiple threads at once. one at a time, bestie. periodt. π
π AVAILABILITY π
This function is available since SDL 3.2.0. so if you're on anything olderβ¦ no it isn't. π
π SEE ALSO π
and that's the whole page, no cap. brought to you by the fine people at Simple Directmedia Layer, running SDL 3.4.18, and yes the manual page is literally called SDL_ReadProcess(3) β iykyk. go read some process output, you ate. πβ¨π
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms