process_unix.h 2.3 KB

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