SDL3pp
A slim C++ wrapper for SDL3
|
Process control support. More...
Classes | |
struct | SDL::ProcessBase |
An opaque handle representing a system process. More... | |
struct | SDL::ProcessRef |
Handle to a non owned process. More... | |
struct | SDL::Process |
Handle to an owned process. More... | |
Typedefs | |
using | SDL::ProcessIO = SDL_ProcessIO |
Description of where standard I/O should be directed when creating a process. | |
Variables | |
constexpr ProcessIO | SDL::PROCESS_STDIO_INHERITED |
The I/O stream is inherited from the application. | |
constexpr ProcessIO | SDL::PROCESS_STDIO_NULL |
The I/O stream is ignored. | |
constexpr ProcessIO | SDL::PROCESS_STDIO_APP = SDL_PROCESS_STDIO_APP |
The I/O stream is connected to a new IOStreamBase that the application can read or write. | |
constexpr ProcessIO | SDL::PROCESS_STDIO_REDIRECT = SDL_PROCESS_STDIO_REDIRECT |
The I/O stream is redirected to an existing IOStreamBase. | |
These functions provide a cross-platform way to spawn and manage OS-level processes.
You can create a new subprocess with ProcessBase.ProcessBase() and optionally read and write to it using ProcessBase.Read() or ProcessBase.GetInput() and ProcessBase.GetOutput(). If more advanced functionality like chaining input between processes is necessary, you can use ProcessBase.ProcessBase().
You can get the status of a created process with ProcessBase.Wait(), or terminate the process with ProcessBase.Kill().
Don't forget to call ProcessRef.reset() to clean up, whether the process process was killed, terminated on its own, or is still running!
using SDL::ProcessIO = typedef SDL_ProcessIO |
If a standard I/O stream is set to PROCESS_STDIO_INHERITED, it will go to the same place as the application's I/O stream. This is the default for standard output and standard error.
If a standard I/O stream is set to SDL_PROCESS_STDIO_NULL, it is connected to NUL:
on Windows and /dev/null
on POSIX systems. This is the default for standard input.
If a standard I/O stream is set to PROCESS_STDIO_APP, it is connected to a new IOStreamBase that is available to the application. Standard input will be available as prop::process.STDIN_POINTER
and allows ProcessBase.GetInput(), standard output will be available as prop::process.STDOUT_POINTER
and allows ProcessBase.Read() and ProcessBase.GetOutput(), and standard error will be available as prop::process.STDERR_POINTER
in the properties for the created process.
If a standard I/O stream is set to PROCESS_STDIO_REDIRECT, it is connected to an existing IOStreamBase provided by the application. Standard input is provided using prop::process.CREATE_STDIN_POINTER
, standard output is provided using prop::process.CREATE_STDOUT_POINTER
, and standard error is provided using prop::process.CREATE_STDERR_POINTER
in the creation properties. These existing streams should be closed by the application once the new process is created.
In order to use an IOStreamBase with PROCESS_STDIO_REDIRECT, it must have prop::IOStream.WINDOWS_HANDLE_POINTER
or prop::IOStream.FILE_DESCRIPTOR_NUMBER
set. This is true for streams representing files and process I/O.
|
constexpr |
|
constexpr |