process_unix.h (2365B)
1 /* Copyright (c) 2003-2004, Roger Dingledine 2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 3 * Copyright (c) 2007-2021, The Tor Project, Inc. */ 4 /* See LICENSE for licensing information */ 5 6 /** 7 * \file process_unix.h 8 * \brief Header for process_unix.c 9 **/ 10 11 #ifndef TOR_PROCESS_UNIX_H 12 #define TOR_PROCESS_UNIX_H 13 14 #ifndef _WIN32 15 16 #include "orconfig.h" 17 #include "lib/malloc/malloc.h" 18 19 #include <event2/event.h> 20 21 struct process_t; 22 23 struct process_unix_t; 24 typedef struct process_unix_t process_unix_t; 25 26 process_unix_t *process_unix_new(void); 27 void process_unix_free_(process_unix_t *unix_process); 28 #define process_unix_free(s) \ 29 FREE_AND_NULL(process_unix_t, process_unix_free_, (s)) 30 31 process_status_t process_unix_exec(struct process_t *process); 32 bool process_unix_terminate(struct process_t *process); 33 34 process_pid_t process_unix_get_pid(struct process_t *process); 35 36 int process_unix_write(struct process_t *process, buf_t *buffer); 37 int process_unix_read_stdout(struct process_t *process, buf_t *buffer); 38 int process_unix_read_stderr(struct process_t *process, buf_t *buffer); 39 40 #ifdef PROCESS_UNIX_PRIVATE 41 struct process_unix_handle_t; 42 typedef struct process_unix_handle_t process_unix_handle_t; 43 44 STATIC void stdout_read_callback(evutil_socket_t fd, short event, void *data); 45 STATIC void stderr_read_callback(evutil_socket_t fd, short event, void *data); 46 STATIC void stdin_write_callback(evutil_socket_t fd, short event, void *data); 47 48 STATIC void process_unix_start_reading(process_unix_handle_t *); 49 STATIC void process_unix_stop_reading(process_unix_handle_t *); 50 51 STATIC void process_unix_start_writing(process_unix_handle_t *); 52 STATIC void process_unix_stop_writing(process_unix_handle_t *); 53 54 STATIC void process_unix_waitpid_callback(int status, void *data); 55 56 STATIC void process_unix_setup_handle(process_t *process, 57 process_unix_handle_t *handle, 58 short flags, 59 event_callback_fn callback); 60 STATIC int process_unix_read_handle(process_t *, 61 process_unix_handle_t *, 62 buf_t *); 63 STATIC bool process_unix_close_file_descriptors(process_unix_t *); 64 #endif /* defined(PROCESS_UNIX_PRIVATE) */ 65 66 #endif /* !defined(_WIN32) */ 67 68 #endif /* !defined(TOR_PROCESS_UNIX_H) */