SDL_ProcessIO(3type)

πŸ’– SDL_ProcessIO πŸ’–

okay bestie, welcome to the SDL3 DATATYPES corner of the man pages 🌸 this one's called SDL_ProcessIO, and it's literally the glow-up guide for where your process's standard I/O goes when you spin one up. no cap.


✨ NAME ✨

SDL_ProcessIO β€” a whole description of where standard I/O should be directed when creating a process. that's it, that's the vibe πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_process.h>

typedef enum SDL_ProcessIO
{
    SDL_PROCESS_STDIO_INHERITED,    /**< The I/O stream is inherited from the application. */
    SDL_PROCESS_STDIO_NULL,         /**< The I/O stream is ignored. */
    SDL_PROCESS_STDIO_APP,          /**< The I/O stream is connected to a new SDL_IOStream that the application can read or write */
    SDL_PROCESS_STDIO_REDIRECT      /**< The I/O stream is redirected to an existing SDL_IOStream. */
} SDL_ProcessIO;

look at her. four little enum girlies, each one with main character energy πŸ‘‘


🌈 DESCRIPTION 🌈

so here's the tea, one stream at a time β˜•

  • SDL_PROCESS_STDIO_INHERITED β€” the I/O stream goes to the exact same place as the application's own I/O stream. sharing is caring fr fr. this is the default for standard output and standard error πŸ’…
  • SDL_PROCESS_STDIO_NULL β€” the stream gets yeeted into the void πŸ•³οΈ it's connected to NUL: on Windows and /dev/null on POSIX systems. this is the default for standard input. stream said "not me participating" πŸ’€
  • SDL_PROCESS_STDIO_APP β€” the stream is connected to a brand new SDL_IOStream that your application can actually get its hands on πŸ™Œ and each one has its own lil home:
    • standard input shows up as SDL_PROP_PROCESS_STDIN_POINTER, and it lets you use SDL_GetProcessInput()
    • standard output shows up as SDL_PROP_PROCESS_STDOUT_POINTER, and it lets you use SDL_ReadProcess() and SDL_GetProcessOutput()
    • standard error shows up as SDL_PROP_PROCESS_STDERR_POINTER
    • all three of those live in the properties for the created process 🫢
  • SDL_PROCESS_STDIO_REDIRECT β€” the stream gets connected to an existing SDL_IOStream that your application provides. here's how each one gets handed over, all in the creation properties:
    • standard input is provided using SDL_PROP_PROCESS_CREATE_STDIN_POINTER
    • standard output is provided using SDL_PROP_PROCESS_CREATE_STDOUT_POINTER
    • standard error is provided using SDL_PROP_PROCESS_CREATE_STDERR_POINTER
⚠️ bestie listen. those existing streams should be closed by the application once the new process is created. don't just leave them hanging, that's messy 😭

and one more tiny-but-huge detail for the redirect girlies:

πŸŽ€ in order to use an SDL_IOStream with SDL_PROCESS_STDIO_REDIRECT, it must have SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER or SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER set. good news tho β€” this is true for streams representing files and process I/O, so you're probably already slaying ✨

πŸ‘‘ AVAILABILITY πŸ‘‘

this enum has been available since SDL 3.2.0. she's not new new, but she ate and left no crumbs πŸ“


πŸ’œ SEE ALSO πŸ’œ

go read these next, they're all in the group chat together:


okay that's the whole page, you're basically a process I/O expert now 🧚✨ this lil cutie came to you courtesy of Simple Directmedia Layer, version SDL 3.4.18 πŸ’– thanks for reading bestie, go forth and spawn responsibly 🫢

πŸ“¦ where this page comes from