sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Bindgen.Process.FunPtr

Synopsis

Documentation

sDL_CreateProcess :: FunPtr (PtrConst (PtrConst CChar) -> CBool -> IO (Ptr SDL_Process)) Source #

Create a new process.

The path to the executable is supplied in args[0]. args[1..N] are additional arguments passed on the command line of the new process, and the argument list should be terminated with a NULL, e.g.:

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

Setting pipe_stdio to true is equivalent to setting sDL_PROP_PROCESS_CREATE_STDIN_NUMBER and sDL_PROP_PROCESS_CREATE_STDOUT_NUMBER to SDL_PROCESS_STDIO_APP, and will allow the use of SDL_ReadProcess() or SDL_GetProcessInput() and SDL_GetProcessOutput().

See SDL_CreateProcessWithProperties() for more details.

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.
Returns
the newly created and running process, or NULL if the process couldn't be created.
Thread safety
It is safe to call this function from any thread.
See also
sDL_CreateProcessWithProperties, sDL_GetProcessProperties, sDL_ReadProcess, sDL_GetProcessInput, sDL_GetProcessOutput, sDL_KillProcess, sDL_WaitProcess, sDL_DestroyProcess
C declaration
SDL_CreateProcess, defined at SDL3/SDL_process.h 106:43

Since: 3.2.0

sDL_CreateProcessWithProperties :: FunPtr (SDL_PropertiesID -> IO (Ptr SDL_Process)) Source #

Create a new process with the specified properties.

These are the supported properties:

On POSIX platforms, wait() and waitpid(-1, ...) should not be called, and SIGCHLD should not be ignored or handled because those would prevent SDL from properly tracking the lifetime of the underlying process. You should use SDL_WaitProcess() instead.

props
the properties to use.
Returns
the newly created and running process, or NULL if the process couldn't be created.
Thread safety
It is safe to call this function from any thread.
See also
sDL_CreateProcess, sDL_GetProcessProperties, sDL_ReadProcess, sDL_GetProcessInput, sDL_GetProcessOutput, sDL_KillProcess, sDL_WaitProcess, sDL_DestroyProcess
C declaration
SDL_CreateProcessWithProperties, defined at SDL3/SDL_process.h 227:43

Since: 3.2.0

sDL_GetProcessProperties :: FunPtr (Ptr SDL_Process -> IO SDL_PropertiesID) Source #

Get the properties associated with a process.

The following read-only properties are provided by SDL:

process
the process to query.
Returns
a valid property ID on success or 0 on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_CreateProcess, sDL_CreateProcessWithProperties
C declaration
SDL_GetProcessProperties, defined at SDL3/SDL_process.h 271:46

Since: 3.2.0

sDL_ReadProcess :: FunPtr (Ptr SDL_Process -> Ptr CSize -> Ptr CInt -> IO (Ptr Void)) Source #

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

process
The process to read.
datasize
a pointer filled in with the number of bytes read, may be NULL.
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.
Thread safety
This function is not thread safe.
See also
sDL_CreateProcess, sDL_CreateProcessWithProperties, sDL_DestroyProcess
C declaration
SDL_ReadProcess, defined at SDL3/SDL_process.h 308:36

Since: 3.2.0

sDL_GetProcessInput :: FunPtr (Ptr SDL_Process -> IO (Ptr SDL_IOStream)) Source #

Get the SDL_IOStream associated with process standard input.

The process must have been created with SDL_CreateProcess() and pipe_stdio set to true, or with SDL_CreateProcessWithProperties() and sDL_PROP_PROCESS_CREATE_STDIN_NUMBER set to SDL_PROCESS_STDIO_APP.

Writing to this stream can return less data than expected if the process hasn't read its input. It may be blocked waiting for its output to be read, if so you may need to call SDL_GetProcessOutput() and read the output in parallel with writing input.

process
The process to get the input stream for.
Returns
the input stream or NULL on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_CreateProcess, sDL_CreateProcessWithProperties, sDL_GetProcessOutput
C declaration
SDL_GetProcessInput, defined at SDL3/SDL_process.h 334:44

Since: 3.2.0

sDL_GetProcessOutput :: FunPtr (Ptr SDL_Process -> IO (Ptr SDL_IOStream)) Source #

Get the SDL_IOStream associated with process standard output.

The process must have been created with SDL_CreateProcess() and pipe_stdio set to true, or with SDL_CreateProcessWithProperties() and sDL_PROP_PROCESS_CREATE_STDOUT_NUMBER set to SDL_PROCESS_STDIO_APP.

Reading from this stream can return 0 with SDL_GetIOStatus() returning SDL_IO_STATUS_NOT_READY if no output is available yet.

process
The process to get the output stream for.
Returns
the output stream or NULL on failure; call SDL_GetError() for more information.
Thread safety
It is safe to call this function from any thread.
See also
sDL_CreateProcess, sDL_CreateProcessWithProperties, sDL_GetProcessInput
C declaration
SDL_GetProcessOutput, defined at SDL3/SDL_process.h 358:44

Since: 3.2.0

sDL_KillProcess :: FunPtr (Ptr SDL_Process -> CBool -> IO CBool) Source #

Stop a process.

process
The process to stop.
force
true to terminate the process immediately, false to try to stop the process gracefully. In general you should try to stop the process gracefully first as terminating a process may leave it with half-written data or in some other unstable state.
Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
This function is not thread safe.
See also
sDL_CreateProcess, sDL_CreateProcessWithProperties, sDL_WaitProcess, sDL_DestroyProcess
C declaration
SDL_KillProcess, defined at SDL3/SDL_process.h 381:34

Since: 3.2.0

sDL_WaitProcess :: FunPtr (Ptr SDL_Process -> CBool -> Ptr CInt -> IO CBool) Source #

Wait for a process to finish.

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 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;

process
The process to wait for.
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 NULL.
Returns
true if the process exited, false otherwise.
Thread safety
This function is not thread safe.
See also
sDL_CreateProcess, sDL_CreateProcessWithProperties, sDL_KillProcess, sDL_DestroyProcess
C declaration
SDL_WaitProcess, defined at SDL3/SDL_process.h 414:34

Since: 3.2.0

sDL_DestroyProcess :: FunPtr (Ptr SDL_Process -> IO ()) Source #

Destroy a previously created process object.

Note that this does not stop the process, just destroys the SDL object used to track it. If you want to stop the process you should use SDL_KillProcess().

process
The process object to destroy.
Thread safety
This function is not thread safe.
See also
sDL_CreateProcess, sDL_CreateProcessWithProperties, sDL_KillProcess
C declaration
SDL_DestroyProcess, defined at SDL3/SDL_process.h 433:34

Since: 3.2.0