Functions | |
pid_t | cuos_start_prog_fd (char const *prg, char const *const *argv, char *const *envp, int *fd_arr) |
pid_t | cuos_start_prog_io (char const *prg, char const *const *argv, char *const *envp, FILE **in, FILE **out, FILE **err) |
pid_t | cuos_start_prog (char const *prg, char const *const *argv, char *const *envp) |
int | cuos_wait_for_prog (char const *prg, pid_t pid) |
int | cuos_call_prog (char const *prg, char const *const *argv, char *const *envp) |
int | cuos_call_prog_fd (char const *prg, char const *const *argv, char *const *envp, int *fd_arr) |
void | cuos_argv_cct_strlist (char const **argv, cucon_list_t strlist) |
cu_str_t | cuos_shell_escape_cstr (char const *cstr) |
void | cuos_argv_fprint (char const **argv, FILE *out) |
void cuos_argv_cct_strlist | ( | char const ** | argv, | |
cucon_list_t | strlist | |||
) |
Construct a NULL
terminated argv from a cucon_list_t
of cu_str_t
. argv must have at least cucon_list_count (strlist) + 1
elements.
void cuos_argv_fprint | ( | char const ** | argv, | |
FILE * | out | |||
) |
Print out argv to out.
int cuos_call_prog | ( | char const * | prg, | |
char const *const * | argv, | |||
char *const * | envp | |||
) |
Start in a sub-process and wait for the program prg with arguments argv and environment envp. See cuos_start_prog for details.
int cuos_call_prog_fd | ( | char const * | prg, | |
char const *const * | argv, | |||
char *const * | envp, | |||
int * | fd_arr | |||
) |
Start in a sub-process and wait for the program prg with arguments argv, environment envp and redirections fd_arr. See cuos_start_prog_fd for details.
cu_str_t cuos_shell_escape_cstr | ( | char const * | cstr | ) |
Returns 'cstr' with shell special chars (including space) escaped. May quote more than strictly needed.
pid_t cuos_start_prog | ( | char const * | prg, | |
char const *const * | argv, | |||
char *const * | envp | |||
) |
Shortcut for cuos_start_prog_fd when no redirections are needed.
pid_t cuos_start_prog_fd | ( | char const * | prg, | |
char const *const * | argv, | |||
char *const * | envp, | |||
int * | fd_arr | |||
) |
Fork the current process and call
execvp(prg, argv)
in the subprocess. If fd_arr is not NULL, redirect file descriptor i to fd_arr[i] iff fd_arr[i] ≠ -1. The given file descriptors will be closed by this function. The process id is returned.
stdin
in the subprocess, or -1 stdout
in the subprocess, or -1 stderr
in the subprocess, or -1 pid_t cuos_start_prog_io | ( | char const * | prg, | |
char const *const * | argv, | |||
char *const * | envp, | |||
FILE ** | in, | |||
FILE ** | out, | |||
FILE ** | err | |||
) |
Fork the current process and call
execvp(prg, argv)
in the subprocess. For each in, out, err which is non-NULL
, return an open file to the stdin
, stdout
, stderr
of the subprocess. Note that stdin
is opened for writing and the others are opened for reading.
int cuos_wait_for_prog | ( | char const * | prg, | |
pid_t | pid | |||
) |
Wait for the process with process id pid as retured by cuos_start_prog_fd, cuos_start_prog_io, or cuos_start_prog. prg should be the same as the first argument of the corresponding start-function.