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 be NULL, 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 be NULL. 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