39 void (*userfn)(int,
void *userdata);
45static inline unsigned int
48 return (
unsigned) ent->pid;
51static inline unsigned int
55 return a->pid == b->pid;
61 process_map_entries_eq_);
74set_waitpid_callback(pid_t pid,
void (*fn)(
int,
void *),
void *arg)
83 old_ent = HT_REPLACE(process_map, &process_map, ent);
85 log_warn(
LD_BUG,
"Replaced a waitpid monitor on pid %u. That should be "
86 "impossible.", (
unsigned) pid);
105 old_ent = HT_REMOVE(process_map, &process_map, ent);
106 if (old_ent != ent) {
107 log_warn(
LD_BUG,
"Couldn't remove waitpid monitor for pid %u.",
108 (
unsigned) ent->pid);
124 ent = HT_REMOVE(process_map, &process_map, &search);
125 if (!ent || !ent->running) {
126 log_info(
LD_GENERAL,
"Child process %u has exited; no callback was "
127 "registered", (
unsigned)pid);
131 log_info(
LD_GENERAL,
"Child process %u has exited; running callback.",
135 ent->userfn(status, ent->userdata);
148 while ((child = waitpid(-1, &status, WNOHANG)) > 0) {
HT_PROTOTYPE(hs_circuitmap_ht, circuit_t, hs_circuitmap_node, hs_circuit_hash_token, hs_circuits_have_same_token)
typedef HT_HEAD(hs_service_ht, hs_service_t) hs_service_ht
void * tor_reallocarray_(void *ptr, size_t sz1, size_t sz2)
void tor_free_(void *mem)
Headers for util_malloc.c.
Macros to manage assertions, fatal and non-fatal.
static void notify_waitpid_callback_by_pid(pid_t pid, int status)
void notify_pending_waitpid_callbacks(void)
void clear_waitpid_callback(waitpid_callback_t *ent)