VLC 4.0.0-dev
Loading...
Searching...
No Matches
Process API

Functions

struct vlc_processvlc_process_Spawn (const char *path, int argc, const char *const *argv)
 Spawn a new process with input and output redirection.
 
int vlc_process_Terminate (struct vlc_process *process, bool kill_process)
 Stop a vlc_process and wait for its termination.
 
ssize_t vlc_process_fd_Read (struct vlc_process *process, uint8_t *buf, size_t size, vlc_tick_t timeout_ms)
 Read data from the process's standard output with a timeout.
 
ssize_t vlc_process_fd_Write (struct vlc_process *process, const uint8_t *buf, size_t size, vlc_tick_t timeout_ms)
 Write data to the process's standard input with a timeout.
 

Detailed Description

Function Documentation

◆ vlc_process_fd_Read()

ssize_t vlc_process_fd_Read ( struct vlc_process process,
uint8_t *  buf,
size_t  size,
vlc_tick_t  timeout_ms 
)

Read data from the process's standard output with a timeout.

Attempts to read up to size bytes from the process's standard output into the provided buffer, waiting up to timeout_ms milliseconds for data to become available.

On POSIX systems, this uses poll to wait for readability. On Windows, a platform-specific implementation is used due to limitations with poll on non-socket handles.

Parameters
[in]processPointer to the vlc_process instance.
[out]bufBuffer where the read data will be stored.
[in]sizeMaximum number of bytes to read.
[in]timeout_msTimeout in milliseconds to wait for data.
Returns
The number of bytes read on success, -1 on error, and errno is set to indicate the error.

References pollfd::fd, vlc_process::fd, vlc_process::fd_in, vlc_process::hEvent, POLLIN, pollfd::revents, vlc_assert_unreachable, vlc_poll_i11e(), vlc_process_WindowsPoll(), VLC_SUCCESS, and VLC_UNUSED.

Referenced by read_cbs().

◆ vlc_process_fd_Write()

ssize_t vlc_process_fd_Write ( struct vlc_process process,
const uint8_t *  buf,
size_t  size,
vlc_tick_t  timeout_ms 
)

Write data to the process's standard input with a timeout.

Attempts to write up to size bytes from the provided buffer to the process's standard input, waiting up to timeout_ms milliseconds for the pipe to become writable.

On POSIX systems, this uses poll to wait for writability. On Windows, a platform-specific implementation is used due to limitations with poll on non-socket handles.

Parameters
[in]processPointer to the vlc_process instance.
[in]bufBuffer containing the data to write.
[in]sizeNumber of bytes to write.
[in]timeout_msTimeout in milliseconds to wait for the pipe to be writable.
Returns
The number of bytes read on success, -1 on error, and errno is set to indicate the error.

References pollfd::fd, vlc_process::fd, vlc_process::fd_out, vlc_process::hEvent, POLLOUT, pollfd::revents, vlc_assert_unreachable, vlc_poll_i11e(), vlc_process_WindowsPoll(), vlc_send_i11e(), VLC_SUCCESS, and VLC_UNUSED.

Referenced by write_cbs().

◆ vlc_process_Spawn()

struct vlc_process * vlc_process_Spawn ( const char *  path,
int  argc,
const char *const *  argv 
)

Spawn a new process with input and output redirection.

Creates and starts a new vlc_process for the specified executable path with the given arguments. Sets up pipes to allow reading from the process's standard output and writing to its standard input.

Parameters
[in]pathPath to the executable to run. Must not be NULL.
[in]argcNumber of arguments passed to the process (must be greater than 0).
[in]argvArray of argument strings (argv[0] must not be NULL).
Returns
A pointer to the newly created vlc_process structure on success, or NULL on failure.

References vlc_process::fd, vlc_process::fd_in, vlc_process::fd_out, vlc_process::hEvent, net_Close, vlc_process::pid, vlc_close(), vlc_dup(), VLC_EGENERIC, VLC_ENOMEM, vlc_pipe(), vlc_socketpair(), vlc_spawnp(), and VLC_UNUSED.

Referenced by preparser_pool_SpawnProcess().

◆ vlc_process_Terminate()

int vlc_process_Terminate ( struct vlc_process process,
bool  kill_process 
)

Stop a vlc_process and wait for its termination.

Closes its file descriptors, and waits for it to exit. Optionally sends a termination signal to the process,

Parameters
[in]processPointer to the vlc_process instance. Must not be NULL.
[in]kill_processWhether to forcibly terminate the process before waiting.
Returns
The exit status of the process, or -1 on error.

References vlc_process::fd, vlc_process::fd_in, vlc_process::fd_out, vlc_process::hEvent, net_Close, vlc_process::pid, vlc_assert_unreachable, vlc_close(), VLC_UNUSED, and vlc_waitpid().

Referenced by preparser_pool_Delete(), preparser_pool_Run(), and preparser_pool_SpawnThread().