Tor  0.4.7.0-alpha-dev
Data Structures | Macros | Functions | Variables
procmon.c File Reference

Process-termination monitor functions. More...

#include "lib/evloop/procmon.h"
#include "lib/log/log.h"
#include "lib/log/util_bug.h"
#include "lib/log/win32err.h"
#include "lib/malloc/malloc.h"
#include "lib/string/parse_int.h"

Go to the source code of this file.

Data Structures

struct  parsed_process_specifier_t
 
struct  tor_process_monitor_t
 

Macros

#define PID_T_FORMAT   "%d"
 
#define PROCMON_POLLS   1
 

Functions

static void tor_process_monitor_poll_cb (periodic_timer_t *ev, void *procmon_)
 
static int parse_process_specifier (const char *process_spec, struct parsed_process_specifier_t *ppspec, const char **msg)
 
int tor_validate_process_specifier (const char *process_spec, const char **msg)
 
tor_process_monitor_ttor_process_monitor_new (struct event_base *base, const char *process_spec, log_domain_mask_t log_domain, tor_procmon_callback_t cb, void *cb_arg, const char **msg)
 
void tor_process_monitor_free_ (tor_process_monitor_t *procmon)
 

Variables

static const struct timeval poll_interval_tv = {15, 0}
 

Detailed Description

Process-termination monitor functions.

Definition in file procmon.c.

Function Documentation

◆ parse_process_specifier()

static int parse_process_specifier ( const char *  process_spec,
struct parsed_process_specifier_t ppspec,
const char **  msg 
)
static

Parse the process specifier given in process_spec into *ppspec. Return 0 on success; return -1 and store an error message into *msg on failure. The caller must not free the returned error message.

Definition at line 70 of file procmon.c.

Referenced by tor_validate_process_specifier().

◆ tor_process_monitor_free_()

void tor_process_monitor_free_ ( tor_process_monitor_t procmon)

Free the process-termination monitor procmon.

Definition at line 325 of file procmon.c.

◆ tor_process_monitor_new()

tor_process_monitor_t* tor_process_monitor_new ( struct event_base *  base,
const char *  process_spec,
log_domain_mask_t  log_domain,
tor_procmon_callback_t  cb,
void *  cb_arg,
const char **  msg 
)

Create a process-termination monitor for the process specifier given in process_spec. Return a newly allocated tor_process_monitor_t on success; return NULL and store an error message into *msg on failure. The caller must not free the returned error message.

When the monitored process terminates, call cb(cb_arg).

Definition at line 181 of file procmon.c.

◆ tor_process_monitor_poll_cb()

static void tor_process_monitor_poll_cb ( periodic_timer_t event,
void *  procmon_ 
)
static

Libevent callback to poll for the existence of the process monitored by procmon_.

Definition at line 248 of file procmon.c.

◆ tor_validate_process_specifier()

int tor_validate_process_specifier ( const char *  process_spec,
const char **  msg 
)

Verify that the process specifier given in process_spec is syntactically valid. Return 0 on success; return -1 and store an error message into *msg on failure. The caller must not free the returned error message.

Definition at line 157 of file procmon.c.