SDL_WaitProcess(3)

✨ SDL_WaitProcess(3) ✨

okay bestie come SIT with me because we're doing SDL_WaitProcess from the SDL3 FUNCTIONS lineup and honestly? it's giving "chill little function with one giant trap" πŸ’…


πŸŽ€ NAME πŸŽ€

SDL_WaitProcess β€” wait for a process to finish. that's it, that's the whole job, no cap. 🫢


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_process.h>

bool SDL_WaitProcess(SDL_Process *process, bool block, int *exitcode);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like. you can call this thing multiple times to just keep checking on the status of a process. it's not a one-and-done situation, she's reusable, she's flexible, she's the moment ✨

the exit code you get back will be one of these three vibes:

  • the actual exit code of the process, if it terminated normally 🌈
  • a negative signal, if it terminated because of a signal πŸ’€
  • or -255 otherwise πŸ™ˆ

and here's the key part: if the process is still running, the exit code will not be changed. so don't come for her, she didn't touch it.

now for the part where you need to pay attention, bestie. if you created a process with standard output piped to the application (pipe_stdio being true), then you must read all of the process output before you call SDL_WaitProcess(). if you don't do this? the process might be blocked indefinitely waiting for output to be read, and SDL_WaitProcess() will never return true. like, ever. forever stuck. not the vibe. 😭

fr fr: read your pipe output first. do not skip this step. this is the whole plot twist of this manpage.

🧚 FUNCTION PARAMETERS 🧚

  • process β€” the process you're waiting on. the one and only. πŸ‘‘
  • block β€” if true, block until the process finishes; otherwise, just report on the process' status. so like, do you wanna sit and wait, or do you wanna peek and go? 🫣
  • exitcode β€” a pointer that gets filled in with the process exit code if the process has exited. may be NULL. yeah she's optional, she's low-maintenance. πŸŽ€

⭐ RETURN VALUE ⭐

returns true if the process exited, false otherwise. binary queen. slay. πŸ’–


πŸ’œ THREAD SAFETY πŸ’œ

this function is not thread safe. so don't be out here sharing her across threads, she's not built for that drama. πŸ™…β™€οΈ


🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. so if you're on anything older, she's not there yet, sorry babe. ✨


πŸ”₯ SEE ALSO πŸ”₯

go read those too, iykyk. the whole process saga is a journey and these are her besties. 🫢


and that's the whole page, bestie. take care of your pipes, check your exit codes, and remember: multiple calls are fine, blocked processes are not. periodt. πŸ’…

sending you off with love from the Simple Directmedia Layer crew β€” this is SDL 3.4.18 energy, dated in the classic SDL_WaitProcess(3) style, and yes the version number goes at the bottom like a little signature. mwah. πŸ˜˜πŸŽ€

πŸ“¦ where this page comes from