SDL_GetProcessInput(3)

πŸ’– SDL_GetProcessInput β€” the SDL3 functions era πŸ’–

okay bestie, we're in the SDL3 FUNCTIONS section of the manual and this one is genuinely a little cutie. let's get into it 🫢


✨ NAME ✨

SDL_GetProcessInput β€” grab the SDL_IOStream that's wired up to a process's standard input. like, the little tube you yell into so the process hears you πŸ’Œ


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_process.h>

SDL_IOStream * SDL_GetProcessInput(SDL_Process *process);

πŸŽ€ DESCRIPTION πŸŽ€

so here's the vibe check first, because there's a prerequisite and she is not optional:

the process has to have been made either

  • with SDL_CreateProcess() and pipe_stdio set to true, or
  • with SDL_CreateProcessWithProperties() and SDL_PROP_PROCESS_CREATE_STDIN_NUMBER set to SDL_PROCESS_STDIO_APP.

no cap, if you didn't set that up, this function is giving nothing.

now the messy part, and lowkey it's the thing that gets everyone 😭 β€” writing to this stream can return less data than you expected if the process hasn't read its input yet. why? because the process might be blocked, sitting there waiting for its output to be read. mutual standoff energy fr fr πŸ’€

so if that's happening, you may need to call SDL_GetProcessOutput() and read the output in parallel with writing input. yes, at the same time. iconic multitasking, that's the assignment πŸ‘‘


πŸ’… FUNCTION PARAMETERS πŸ’…

  • process β€” the process you want the input stream for. your main character. the one you're feeding 🌈

πŸ¦‹ RETURN VALUE πŸ¦‹

returns the input stream, or NULL on failure 😭 β€” and if you get that NULL, call SDL_GetError() for more information. she will tell you what went wrong, just ask her πŸ’œ


πŸ”₯ THREAD SAFETY πŸ”₯

it is safe to call this function from any thread. go wild, bestie, every thread gets a turn ✨


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. so if you're on something older... nope, not for you πŸ™ˆ


πŸ’– SEE ALSO πŸ’–


and that's the whole page, bestie! no crumbs left πŸ“

ok final sign-off: this lil masterpiece comes to you from Simple Directmedia Layer, and the version riding shotgun is SDL 3.4.18. that's the source, that's the version, that's the whole footer moment β€” periodt πŸ’…βœ¨πŸ§š
πŸ“¦ where this page comes from