sdlReadProcess function

Pointer<NativeType> sdlReadProcess(
  1. Pointer<SdlProcess> process,
  2. Pointer<Uint32> datasize,
  3. Pointer<Int32> exitcode
)

Read all the output from a process.

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 SDL_free().

\param process The process to read. \param datasize a pointer filled in with the number of bytes read, may be NULL. \param exitcode a pointer filled in with the process exit code if the process has exited, may be NULL. \returns the data or NULL on failure; call SDL_GetError() for more information.

\threadsafety This function is not thread safe.

\since This function is available since SDL 3.1.3.

\sa SDL_CreateProcess \sa SDL_CreateProcessWithProperties \sa SDL_DestroyProcess

extern SDL_DECLSPEC void * SDLCALL SDL_ReadProcess(SDL_Process *process, size_t *datasize, int *exitcode)

Implementation

Pointer<NativeType> sdlReadProcess(Pointer<SdlProcess> process,
    Pointer<Uint32> datasize, Pointer<Int32> exitcode) {
  final sdlReadProcessLookupFunction = libSdl3.lookupFunction<
      Pointer<NativeType> Function(Pointer<SdlProcess> process,
          Pointer<Uint32> datasize, Pointer<Int32> exitcode),
      Pointer<NativeType> Function(
          Pointer<SdlProcess> process,
          Pointer<Uint32> datasize,
          Pointer<Int32> exitcode)>('SDL_ReadProcess');
  return sdlReadProcessLookupFunction(process, datasize, exitcode);
}