|
| ProcessBase (const char *const *args, bool pipe_stdio) |
| Create a new process.
|
|
| ProcessBase (PropertiesBase &props) |
| Create a new process with the specified properties.
|
|
PropertiesRef | GetProperties () const |
| Get the properties associated with a process.
|
|
StringResult | Read (int *exitcode=nullptr) |
| Read all the output from a process.
|
|
template<class T > |
OwnArray< T > | ReadAs (int *exitcode=nullptr) |
| Read all the output from a process.
|
|
IOStreamRef | GetInput () |
| Get the IOStreamBase associated with process standard input.
|
|
IOStreamRef | GetOutput () |
| Get the IOStreamBase associated with process standard output.
|
|
void | Kill (bool force) |
| Stop a process.
|
|
bool | Wait (bool block, int *exitcode) |
| Wait for a process to finish.
|
|
constexpr | Resource (T resource={}) |
| Constructs the underlying resource.
|
|
constexpr | Resource (std::nullptr_t) |
| Equivalent to default ctor.
|
|
constexpr | Resource (std::nullopt_t) |
| Equivalent to default ctor.
|
|
| Resource (const Resource &other)=delete |
|
| Resource (Resource &&other)=delete |
|
constexpr | Resource (SDL_Process * resource={}) |
| Constructs the underlying resource.
|
|
constexpr | Resource (std::nullptr_t) |
| Equivalent to default ctor.
|
|
constexpr | Resource (std::nullopt_t) |
| Equivalent to default ctor.
|
|
| Resource (const Resource &other)=delete |
|
| Resource (Resource &&other)=delete |
|
Resource & | operator= (const Resource &other)=delete |
|
Resource & | operator= (Resource &&other)=delete |
|
constexpr | operator bool () const |
| True if contains a valid resource.
|
|
constexpr bool | operator== (const Resource &other) const=default |
| Comparison.
|
|
constexpr bool | operator== (std::nullopt_t) const |
| Comparison.
|
|
constexpr bool | operator== (std::nullptr_t) const |
| Comparison.
|
|
constexpr SDL_Process * | get () const |
| Return contained resource;.
|
|
constexpr SDL_Process * | release (SDL_Process * newResource={}) |
| Return contained resource and empties or replace value.
|
|
constexpr const SDL_Process * | operator-> () const |
| Access to fields.
|
|
constexpr SDL_Process * | operator-> () |
| Access to fields.
|
|
StringResult SDL::ProcessBase::Read |
( |
int * |
exitcode = nullptr | ) |
|
|
inline |
If a process was created with I/O enabled, you can use this function to read the output. This function blocks until the process is complete, capturing all output, and providing the process exit code.
The data is allocated with a zero byte at the end (null terminated) for convenience. This extra byte is not included in the value reported via datasize
.
The data should be freed with free().
- Parameters
-
exitcode | a pointer filled in with the process exit code if the process has exited, may be nullptr. |
- Returns
- the data on success.
- Exceptions
-
- Thread safety:
- This function is not thread safe.
- Since
- This function is available since SDL 3.2.0.
- See also
- ProcessBase.ProcessBase
template<class T >
OwnArray< T > SDL::ProcessBase::ReadAs |
( |
int * |
exitcode = nullptr | ) |
|
|
inline |
If a process was created with I/O enabled, you can use this function to read the output. This function blocks until the process is complete, capturing all output, and providing the process exit code.
The data is allocated with a zero byte at the end (null terminated) for convenience. This extra byte is not included in the value reported via datasize
.
The data should be freed with free().
- Parameters
-
exitcode | a pointer filled in with the process exit code if the process has exited, may be nullptr. |
- Returns
- the data or nullptr on failure; call GetError() for more information.
- Thread safety:
- This function is not thread safe.
- Since
- This function is available since SDL 3.2.0.
- See also
- ProcessBase.ProcessBase
bool SDL::ProcessBase::Wait |
( |
bool |
block, |
|
|
int * |
exitcode |
|
) |
| |
|
inline |
This can be called multiple times to get the status of a process.
The exit code will be the exit code of the process if it terminates normally, a negative signal if it terminated due to a signal, or -255 otherwise. It will not be changed if the process is still running.
If you create a process with standard output piped to the application (pipe_stdio
being true) then you should read all of the process output before calling ProcessBase.Wait(). If you don't do this the process might be blocked indefinitely waiting for output to be read and ProcessBase.Wait() will never return true;
- Parameters
-
block | If true, block until the process finishes; otherwise, report on the process' status. |
exitcode | a pointer filled in with the process exit code if the process has exited, may be nullptr. |
- Returns
- true if the process exited, false otherwise.
- Thread safety:
- This function is not thread safe.
- Since
- This function is available since SDL 3.2.0.
- See also
- ProcessBase.ProcessBase
-
ProcessBase.ProcessBase
-
ProcessBase.Kill
-
ProcessRef.reset