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 */
8 * \brief Header for process_unix.c
11 #ifndef TOR_PROCESS_UNIX_H
12 #define TOR_PROCESS_UNIX_H
17 #include "lib/malloc/malloc.h"
19 #include <event2/event.h>
23 struct process_unix_t
;
24 typedef struct process_unix_t process_unix_t
;
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))
31 process_status_t
process_unix_exec(struct process_t
*process
);
32 bool process_unix_terminate(struct process_t
*process
);
34 process_pid_t
process_unix_get_pid(struct process_t
*process
);
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
);
40 #ifdef PROCESS_UNIX_PRIVATE
41 struct process_unix_handle_t
;
42 typedef struct process_unix_handle_t process_unix_handle_t
;
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
);
48 STATIC
void process_unix_start_reading(process_unix_handle_t
*);
49 STATIC
void process_unix_stop_reading(process_unix_handle_t
*);
51 STATIC
void process_unix_start_writing(process_unix_handle_t
*);
52 STATIC
void process_unix_stop_writing(process_unix_handle_t
*);
54 STATIC
void process_unix_waitpid_callback(int status
, void *data
);
56 STATIC
void process_unix_setup_handle(process_t
*process
,
57 process_unix_handle_t
*handle
,
59 event_callback_fn callback
);
60 STATIC
int process_unix_read_handle(process_t
*,
61 process_unix_handle_t
*,
63 STATIC
bool process_unix_close_file_descriptors(process_unix_t
*);
64 #endif /* defined(PROCESS_UNIX_PRIVATE) */
66 #endif /* !defined(_WIN32) */
68 #endif /* !defined(TOR_PROCESS_UNIX_H) */