Tor
0.4.7.0-alpha-dev
|
#include "orconfig.h"
#include "lib/malloc/malloc.h"
#include "lib/string/printf.h"
#include <stdbool.h>
Go to the source code of this file.
Macros | |
#define | PROCESS_MAX_WRITE (1024) |
#define | PROCESS_MAX_READ (1024) |
#define | process_free(s) FREE_AND_NULL(process_t, process_free_, (s)) |
Typedefs | |
typedef uint64_t | process_exit_code_t |
typedef uint64_t | process_pid_t |
typedef void(* | process_read_callback_t) (process_t *, const char *, size_t) |
typedef bool(* | process_exit_callback_t) (process_t *, process_exit_code_t) |
Enumerations | |
enum | process_status_t { PROCESS_STATUS_NOT_RUNNING , PROCESS_STATUS_RUNNING , PROCESS_STATUS_ERROR } |
enum | process_protocol_t { PROCESS_PROTOCOL_LINE , PROCESS_PROTOCOL_RAW } |
#define PROCESS_MAX_READ (1024) |
#define PROCESS_MAX_WRITE (1024) |
enum process_protocol_t |
enum process_status_t |
void process_append_argument | ( | process_t * | process, |
const char * | argument | ||
) |
process_status_t process_exec | ( | process_t * | process | ) |
void process_free_ | ( | process_t * | process | ) |
void process_free_all | ( | void | ) |
const struct smartlist_t* process_get_all_processes | ( | void | ) |
const struct smartlist_t* process_get_arguments | ( | const process_t * | process | ) |
char** process_get_argv | ( | const process_t * | process | ) |
Returns a newly allocated Unix style argument vector. Use tor_free() to deallocate it after use.
Generate a Unix style process argument vector from our process's arguments smartlist_t.
const char* process_get_command | ( | const process_t * | process | ) |
void* process_get_data | ( | const process_t * | process | ) |
Get the opaque pointer to callback data from the given process. This function allows you get the data you stored with process_set_data() in the different callback functions.
Definition at line 395 of file process.c.
Referenced by managed_proxy_stderr_callback(), and managed_proxy_stdout_callback().
struct process_environment_t* process_get_environment | ( | const process_t * | process | ) |
Returns a newly allocated process_environment_t containing the environment variables for the given process.
process_pid_t process_get_pid | ( | process_t * | process | ) |
process_protocol_t process_get_protocol | ( | const process_t * | process | ) |
process_status_t process_get_status | ( | const process_t * | process | ) |
Get the status of the given process.
Definition at line 411 of file process.c.
Referenced by process_terminate().
struct process_unix_t* process_get_unix_process | ( | const process_t * | process | ) |
Get the internal handle for the Unix backend.
Definition at line 510 of file process.c.
Referenced by process_unix_exec(), process_unix_get_pid(), process_unix_read_stderr(), process_unix_read_stdout(), process_unix_terminate(), and process_unix_write().
void process_init | ( | void | ) |
Initialize the Process subsystem. This function initializes the Process subsystem's global state. For cleaning up, process_free_all() should be called.
process_t* process_new | ( | const char * | command | ) |
Allocate and initialize a new process. This function returns a newly allocated and initialized process data, which can be used to configure and later run a subprocess of Tor. Use the various process_set_*() methods to configure it and run the process using process_exec(). Use command to specify the path to the command to run. You can either specify an absolute path to the command or relative where Tor will use the underlying operating system's functionality for finding the command to run.
void process_notify_event_exit | ( | process_t * | process, |
process_exit_code_t | exit_code | ||
) |
This function is called by the Process backend when a given process have terminated. The exit status code is passed in exit_code. We mark the process as no longer running and calls the exit_callback with information about the process termination. The given process is free'd iff the exit_callback returns true.
void process_notify_event_stderr | ( | process_t * | process | ) |
This function is called by the Process backend when a given process have data that is ready to be read from the child process's standard error handle.
Definition at line 594 of file process.c.
Referenced by stderr_read_callback().
void process_notify_event_stdin | ( | process_t * | process | ) |
This function is called by the Process backend when a given process is allowed to begin writing data to the standard input of the child process.
Definition at line 610 of file process.c.
Referenced by stdin_write_callback().
void process_notify_event_stdout | ( | process_t * | process | ) |
This function is called by the Process backend when a given process have data that is ready to be read from the child process's standard output handle.
Definition at line 577 of file process.c.
Referenced by stdout_read_callback().
void process_printf | ( | process_t * | process, |
const char * | format, | ||
... | |||
) |
As tor_snprintf(), but write the data to the given process's standard input.
const char* process_protocol_to_string | ( | process_protocol_t | protocol | ) |
void process_set_data | ( | process_t * | process, |
void * | data | ||
) |
Set opaque pointer to data. This function allows you to store a pointer to your own data in the given process. Use process_get_data() in the various callback functions to retrieve the data again.
Note that the given process does NOT take ownership of the data and you are responsible for freeing up any resources allocated by the given data.
Definition at line 385 of file process.c.
Referenced by launch_managed_proxy(), and proxy_prepare_for_restart().
void process_set_environment | ( | process_t * | process, |
const char * | key, | ||
const char * | value | ||
) |
void process_set_exit_callback | ( | process_t * | process, |
process_exit_callback_t | callback | ||
) |
Set the callback function for process exit notification. The callback function will be called every time your child process have terminated.
Definition at line 347 of file process.c.
Referenced by launch_managed_proxy().
void process_set_status | ( | process_t * | process, |
process_status_t | status | ||
) |
void process_set_stderr_read_callback | ( | process_t * | process, |
process_read_callback_t | callback | ||
) |
Set the callback function for output from the child process's standard error handle. This function sets the callback function which is called every time the child process have written output to its standard error file handle.
Use process_set_protocol(process, PROCESS_PROTOCOL_LINE) if you want the callback to only contain complete "\n" or "\r\n" terminated lines.
Definition at line 336 of file process.c.
Referenced by launch_managed_proxy().
void process_set_stdout_read_callback | ( | process_t * | process, |
process_read_callback_t | callback | ||
) |
Set the callback function for output from the child process's standard out handle. This function sets the callback function which is called every time the child process have written output to its standard out file handle.
Use process_set_protocol(process, PROCESS_PROTOCOL_LINE) if you want the callback to only contain complete "\n" or "\r\n" terminated lines.
Definition at line 321 of file process.c.
Referenced by launch_managed_proxy().
const char* process_status_to_string | ( | process_status_t | status | ) |
bool process_terminate | ( | process_t * | process | ) |
Terminate the given process. Returns true on success, otherwise false.
Definition at line 284 of file process.c.
Referenced by proxy_prepare_for_restart().
void process_vprintf | ( | process_t * | process, |
const char * | format, | ||
va_list | args | ||
) |
As tor_vsnprintf(), but write the data to the given process's standard input.
Definition at line 543 of file process.c.
Referenced by process_printf().
void process_write | ( | process_t * | process, |
const uint8_t * | data, | ||
size_t | size | ||
) |
Write size bytes of data to the given process's standard input.
Definition at line 530 of file process.c.
Referenced by process_vprintf().
void tor_disable_spawning_background_processes | ( | void | ) |
Turn off may_spawn_background_process, so that all future calls to tor_spawn_background are guaranteed to fail.
Definition at line 132 of file process.c.
Referenced by options_act().