Subprocesses in C for RAD

The following are subprocesses in the C language for RAD:

exec_params_t *rad_exec_params_alloc

Allocates a control structure for executing a subprocess.

void rad_exec_params_free(exec_params_t *params);

Frees a subprocess control structure, params.

void rad_exec_params_set_cwd(exec_params_t *params, const char *cwd);

Sets the current working directory, cwd, in a subprocess control structure, params.

void rad_exec_params_set_env(exec_params_t *params, const char **envp);

Sets the environment, envp, in a subprocess control structure, params.

void rad_exec_params_set_loglevel(exec_params_t *params, rad_logtype_t loglevel);

Sets the RAD log level, loglevel, in a subprocess control structure, params.

int rad_exec_params_set_stdin(exec_params_t *params, int fd);

Sets the stdin file descriptor, fd, in a subprocess control structure, params.

int rad_exec_params_set_stdout(exec_params_t *params,int fd);

Sets the stdout file descriptor, fd, in a subprocess control structure, params.

int rad_exec_params_set_stderr(exec_params_t *params, int fd);

Sets the stderr file descriptor, fd, in a subprocess control structure, params.

int rad_forkexec(exec_params_t *params, const char **argv, exec_result_t *result);

Uses the supplied subprocess control structure, params, to fork and execute (execv) the supplied args, argv. If result is not NULL, it is updated with the subprocess pid and file descriptor details.

int rad_forkexec_wait(exec_params_t *params, const char **argv, int *status);

Uses the supplied subprocess control structure, params, to fork and execute (execv) the supplied args, argv. If status is not NULL, it is updated with the exit status of the subprocess. This function will wait for the subprocess to terminate before returning.

int rad_wait(exec_params_t *params, exec_result_t *result, int *status);

Uses the supplied subprocess control structure, params, to wait for a previous invocation of rad_forkexe to complete. If result is not NULL, it is updated with the subprocess pid and file descriptor details. If status is not NULL, it is updated with the exit status of the subprocess. This function will wait for the subprocess to terminate before returning.