SDL_CreateProcess(3)

πŸ’– SDL_CreateProcess(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where today we're spawning a whole new process like it's nothing. this is SDL_CreateProcess, and yes it's exactly as iconic as it sounds 🫢


✨ NAME ✨

SDL_CreateProcess β€” Create a new process.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_process.h>

SDL_Process * SDL_CreateProcess(const char * const *args, bool pipe_stdio);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, the path to the executable you wanna run? that goes in args[0]. then args[1..N] are the extra arguments that get passed on the command line of the new process, and β€” this is the important part, don't forget it β€” the argument list has to be terminated with a NULL. no cap. like this:

const char *args[] = { "myprogram", "argument", NULL };

now, setting pipe_stdio to true? that's literally equivalent to setting SDL_PROP_PROCESS_CREATE_STDIN_NUMBER and SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER to SDL_PROCESS_STDIO_APP, and it's what lets you use SDL_ReadProcess() or SDL_GetProcessInput() and SDL_GetProcessOutput(). the way that just works πŸ’…

if you want the full tea, go read SDL_CreateProcessWithProperties() β€” it has more details.


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • args β€” the path and arguments for the new process.
  • pipe_stdio β€” true to create pipes to the process's standard input and from the process's standard output; false for the process to have no input and inherit the application's standard output.

πŸ‘‘ RETURN VALUE πŸ‘‘

Returns the newly created and running process, or NULL if the process couldn't be created. so if you get NULL, it's giving "couldn't make it happen" 😭


πŸ”₯ THREAD SAFETY πŸ”₯

It is safe to call this function from any thread. go off, multithreaded queen ✨


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0.


πŸ’œ SEE ALSO πŸ’œ


and that's the whole page, bestie, you ate that πŸ“ this little love letter came to you from Simple Directmedia Layer, running the SDL 3.4.18 era, and it's the SDL_CreateProcess(3) page. mwah πŸ’–

πŸ“¦ where this page comes from