tor  0.4.2.1-alpha-dev
Macros | Typedefs | Functions
process_unix.h File Reference
#include "orconfig.h"
#include "lib/malloc/malloc.h"
#include <event2/event.h>

Go to the source code of this file.

Macros

#define process_unix_free(s)   FREE_AND_NULL(process_unix_t, process_unix_free_, (s))
 

Typedefs

typedef struct process_unix_t process_unix_t
 

Functions

process_unix_tprocess_unix_new (void)
 
void process_unix_free_ (process_unix_t *unix_process)
 
process_status_t process_unix_exec (struct process_t *process)
 
bool process_unix_terminate (struct process_t *process)
 
process_pid_t process_unix_get_pid (struct process_t *process)
 
int process_unix_write (struct process_t *process, buf_t *buffer)
 
int process_unix_read_stdout (struct process_t *process, buf_t *buffer)
 
int process_unix_read_stderr (struct process_t *process, buf_t *buffer)
 

Detailed Description

Header for process_unix.c.

Definition in file process_unix.h.

Function Documentation

◆ process_unix_exec()

process_status_t process_unix_exec ( process_t process)

Executes the given process as a child process of Tor. This function is responsible for setting up the child process and run it. This includes setting up pipes for interprocess communication, initialize the waitpid callbacks, and finally run fork() followed by execve(). Returns PROCESS_STATUS_RUNNING upon success.

Cleanup standard in pipe.

Cleanup standard in pipe.

Cleanup standard out pipe.

Cleanup standard in pipe.

Cleanup standard out pipe.

Cleanup standard error pipe.

Definition at line 131 of file process_unix.c.

References process_get_unix_process().

◆ process_unix_free_()

void process_unix_free_ ( process_unix_t unix_process)

Deallocates the given unix_process.

Definition at line 104 of file process_unix.c.

References clear_waitpid_callback(), process_unix_close_file_descriptors(), and process_unix_t::waitpid.

◆ process_unix_get_pid()

process_pid_t process_unix_get_pid ( process_t process)

Returns the unique process identifier for the given process.

Definition at line 387 of file process_unix.c.

References process_unix_t::pid, process_get_unix_process(), and tor_assert().

Referenced by process_get_pid().

◆ process_unix_new()

process_unix_t* process_unix_new ( void  )

Returns a newly allocated process_unix_t.

Definition at line 90 of file process_unix.c.

◆ process_unix_read_stderr()

int process_unix_read_stderr ( process_t process,
buf_t *  buffer 
)

Read data from the given process's standard error and put it into buffer. Returns the number of bytes read.

Definition at line 449 of file process_unix.c.

References process_get_unix_process(), process_unix_read_handle(), process_unix_t::stderr_handle, and tor_assert().

◆ process_unix_read_stdout()

int process_unix_read_stdout ( process_t process,
buf_t *  buffer 
)

Read data from the given process's standard output and put it into buffer. Returns the number of bytes read.

Definition at line 434 of file process_unix.c.

References process_get_unix_process(), process_unix_read_handle(), process_unix_t::stdout_handle, and tor_assert().

◆ process_unix_terminate()

bool process_unix_terminate ( process_t process)

Terminate the given process. Returns true on success, otherwise false.

Definition at line 355 of file process_unix.c.

References process_get_unix_process(), and tor_assert().

◆ process_unix_write()

int process_unix_write ( process_t process,
buf_t *  buffer 
)

Write the given buffer as input to the given process's standard input. Returns the number of bytes written.

Definition at line 398 of file process_unix.c.

References process_get_unix_process(), and tor_assert().