Rizin
unix-like reverse engineering framework and cli tools
|
Go to the source code of this file.
Classes | |
struct | rz_process_output_t |
struct | rz_subprocess_opt_t |
Macros | |
#define | RZ_SUBPROCESS_STDIN (1 << 0) |
#define | RZ_SUBPROCESS_STDOUT (1 << 1) |
#define | RZ_SUBPROCESS_STDERR (1 << 2) |
Typedefs | |
typedef enum rz_subprocess_pipe_create_t | RzSubprocessPipeCreate |
typedef enum rz_process_wait_reason_t | RzSubprocessWaitReason |
typedef struct rz_process_output_t | RzSubprocessOutput |
typedef struct rz_subprocess_opt_t | RzSubprocessOpt |
typedef struct rz_subprocess_t | RzSubprocess |
#define RZ_SUBPROCESS_STDERR (1 << 2) |
Definition at line 28 of file rz_subprocess.h.
#define RZ_SUBPROCESS_STDIN (1 << 0) |
Values passed to rz_subprocess API to mention stdin, stdout, stderr or a combination of those
Definition at line 26 of file rz_subprocess.h.
#define RZ_SUBPROCESS_STDOUT (1 << 1) |
Definition at line 27 of file rz_subprocess.h.
typedef struct rz_subprocess_t RzSubprocess |
Definition at line 1 of file rz_subprocess.h.
typedef struct rz_subprocess_opt_t RzSubprocessOpt |
Specify how the new subprocess should be created.
typedef struct rz_process_output_t RzSubprocessOutput |
Provide results from running a sub-process, like output, return value, etc.
typedef enum rz_subprocess_pipe_create_t RzSubprocessPipeCreate |
Enum used to determine how pipes should be created, if at all, in the subprocess.
typedef enum rz_process_wait_reason_t RzSubprocessWaitReason |
Enumerator | |
---|---|
RZ_SUBPROCESS_DEAD | |
RZ_SUBPROCESS_TIMEDOUT | |
RZ_SUBPROCESS_BYTESREAD |
Definition at line 30 of file rz_subprocess.h.
Enum used to determine how pipes should be created, if at all, in the subprocess.
Definition at line 14 of file rz_subprocess.h.
RZ_API RzSubprocessOutput* rz_subprocess_drain | ( | RzSubprocess * | proc | ) |
Definition at line 1260 of file subprocess.c.
References out, proc, RZ_NEW, rz_subprocess_err(), rz_subprocess_out(), subprocess_lock(), and subprocess_unlock().
Referenced by subprocess_runner().
RZ_API ut8* rz_subprocess_err | ( | RzSubprocess * | proc, |
int * | length | ||
) |
Definition at line 1312 of file subprocess.c.
References length, proc, rz_str_newlen(), rz_strbuf_fini(), and rz_strbuf_getbin().
Referenced by rz_subprocess_drain(), rz_sys_cmd_str_full(), and rz_test_run_asm_test().
RZ_API void rz_subprocess_fini | ( | void | ) |
Definition at line 814 of file subprocess.c.
References b, rz_pvector_clear(), rz_sys_pipe_close(), rz_sys_signal(), rz_th_free(), rz_th_lock_free(), rz_th_wait(), rz_xwrite, sigchld_pipe, sigchld_thread, subprocs, and subprocs_mutex.
Referenced by rz_sys_cmd_str_full(), rz_test_main(), system_exec(), and system_exec_stdin().
RZ_API void rz_subprocess_free | ( | RzSubprocess * | proc | ) |
Definition at line 1273 of file subprocess.c.
References free(), proc, rz_pvector_remove_data(), rz_strbuf_fini(), rz_sys_pipe_close(), subprocess_lock(), subprocess_unlock(), and subprocs.
Referenced by rz_sys_cmd_str_full(), rz_test_check_jq_available(), rz_test_check_json_test(), rz_test_run_asm_test(), subprocess_runner(), system_exec(), and system_exec_stdin().
Definition at line 787 of file subprocess.c.
References handle_sigchld(), NULL, rz_pvector_init(), rz_sys_pipe(), rz_sys_pipe_close(), rz_sys_signal(), rz_th_lock_free(), rz_th_lock_new(), rz_th_new(), sigchld_pipe, sigchld_th(), sigchld_thread, subprocs, and subprocs_mutex.
Referenced by rz_sys_cmd_str_full(), rz_test_main(), system_exec(), and system_exec_stdin().
RZ_API void rz_subprocess_kill | ( | RzSubprocess * | proc | ) |
Definition at line 1256 of file subprocess.c.
References kill, proc, and SIGKILL.
Referenced by rz_test_run_asm_test(), and subprocess_runner().
RZ_API ut8* rz_subprocess_out | ( | RzSubprocess * | proc, |
int * | length | ||
) |
Definition at line 1301 of file subprocess.c.
References length, proc, rz_str_newlen(), rz_strbuf_fini(), and rz_strbuf_getbin().
Referenced by rz_subprocess_drain(), rz_sys_cmd_str_full(), rz_test_run_asm_test(), system_exec(), and system_exec_stdin().
RZ_API void rz_subprocess_output_free | ( | RzSubprocessOutput * | out | ) |
RZ_API int rz_subprocess_ret | ( | RzSubprocess * | proc | ) |
Definition at line 1297 of file subprocess.c.
References proc.
Referenced by rz_test_check_jq_available(), rz_test_check_json_test(), rz_test_run_asm_test(), and system_exec().
RZ_API RzSubprocess* rz_subprocess_start | ( | const char * | file, |
const char * | args[], | ||
size_t | args_size, | ||
const char * | envvars[], | ||
const char * | envvals[], | ||
size_t | env_size | ||
) |
Start a program in a new child process with the specified parameters.
file | Name of the program to start. It is also evaluated against PATH |
args | Array of arguments to pass to the new program. It does not include argv[0] |
args_size | Number of arguments in the args array |
envvars | Name of environment variables that the newprocess has different from the parent |
envvals | Values of environment variables that the newprocess has different from the parent. Elements are evaluated in parallel with envvars , so envvals[0] specifies the value of the environment variable named envvars[0] and so on. |
env_size | Number of environment variables in arrays envvars and envvals |
Definition at line 1345 of file subprocess.c.
References args, file, rz_subprocess_opt_t::file, RZ_SUBPROCESS_PIPE_CREATE, and rz_subprocess_start_opt().
Referenced by rz_test_check_jq_available(), rz_test_check_json_test(), rz_test_run_asm_test(), and subprocess_runner().
RZ_API RzSubprocess* rz_subprocess_start_opt | ( | RzSubprocessOpt * | opt | ) |
Definition at line 893 of file subprocess.c.
References rz_subprocess_opt_t::args, rz_subprocess_opt_t::args_size, argv, calloc(), create_child_env(), destroy_child_env(), dup2, EINTR, rz_subprocess_opt_t::env_size, rz_subprocess_opt_t::envvals, rz_subprocess_opt_t::envvars, error(), F_SETFL, fcntl, rz_subprocess_opt_t::file, free(), if(), memcpy(), NULL, O_NONBLOCK, proc, RZ_NEW0, rz_pvector_push(), rz_strbuf_init(), RZ_SUBPROCESS_PIPE_CREATE, RZ_SUBPROCESS_PIPE_STDOUT, rz_sys_execvp(), rz_sys_exit(), rz_sys_fork(), rz_sys_pipe(), rz_sys_pipe_close(), rz_sys_set_environ(), STDERR_FILENO, rz_subprocess_opt_t::stderr_pipe, STDIN_FILENO, rz_subprocess_opt_t::stdin_pipe, stdin_pipe, STDOUT_FILENO, rz_subprocess_opt_t::stdout_pipe, stdout_pipe, subprocess_lock(), subprocess_unlock(), and subprocs.
Referenced by rz_subprocess_start(), rz_sys_cmd_str_full(), system_exec(), and system_exec_stdin().
Sends some data to the stdin of the subprocess and returns the number of bytes sent.
proc | Subprocess to communicate with |
buf | Data that needs to be send to the subprocess stdin |
buf_size | Number of bytes to send |
Definition at line 1206 of file subprocess.c.
References buf_size, proc, rz_sys_signal(), and write.
Referenced by rz_sys_cmd_str_full(), rz_test_check_jq_available(), rz_test_check_json_test(), and system_exec_stdin().
RZ_API RzStrBuf* rz_subprocess_stdout_read | ( | RzSubprocess * | proc, |
size_t | n, | ||
ut64 | timeout_ms | ||
) |
Read some data from the stdout of the subprocess and returns a RzStrBuf
containing it. Callers must not free the returned pointer.
proc | Subprocess to communicate with |
n | Number of bytes to read from the subprocess' stdout |
timeout_ms | Wait for at most this amount of millisecond to read subprocess' stdout |
Definition at line 1225 of file subprocess.c.
References n, proc, rz_strbuf_fini(), rz_strbuf_init(), RZ_SUBPROCESS_STDOUT, and subprocess_wait().
RZ_API RzStrBuf* rz_subprocess_stdout_readline | ( | RzSubprocess * | proc, |
ut64 | timeout_ms | ||
) |
Read one line from the stdout of the subprocess and returns a RzStrBuf
containing it. Callers must not free the returned pointer.
proc | Subprocess to communicate with |
timeout_ms | Wait for at most this amount of millisecond to read subprocess' stdout |
Definition at line 1241 of file subprocess.c.
References c, proc, rz_strbuf_fini(), rz_strbuf_get(), rz_strbuf_init(), rz_strbuf_length(), RZ_SUBPROCESS_BYTESREAD, RZ_SUBPROCESS_STDOUT, and subprocess_wait().
RZ_API RzSubprocessWaitReason rz_subprocess_wait | ( | RzSubprocess * | proc, |
ut64 | timeout_ms | ||
) |
Wait until process dies or timeout expires and collect stdout + stderr. No more input can be sent after this call.
proc | Subprocess to communicate with |
timeout_ms | Wait for at most this amount of millisecond |
Definition at line 1185 of file subprocess.c.
References proc, rz_strbuf_fini(), rz_strbuf_init(), RZ_SUBPROCESS_STDERR, RZ_SUBPROCESS_STDOUT, rz_sys_pipe_close(), and subprocess_wait().
Referenced by rz_sys_cmd_str_full(), rz_test_check_jq_available(), rz_test_check_json_test(), rz_test_run_asm_test(), subprocess_runner(), system_exec(), and system_exec_stdin().