diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-11-25 16:47:25 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-11-25 16:47:25 -0500 |
commit | d6c18c5804f12f8f4428abce11fc47c64d2a0dd0 (patch) | |
tree | bfdb802f129bec4558f52d7228bf07371f8c9f6d /src/common/util.h | |
parent | 093e6724c7c64c4472cf5426db0e34b650aa2f44 (diff) | |
download | tor-d6c18c5804f12f8f4428abce11fc47c64d2a0dd0.tar.gz tor-d6c18c5804f12f8f4428abce11fc47c64d2a0dd0.zip |
Make process_handle_t private and fix some unit tests
Let's *not* expose more cross-platform-compatibility structures, or
expect code to use them right.
Also, don't fclose() stdout_handle and stdin_handle until we do
tor_process_handle_destroy, or we risk a double-fclose.
Diffstat (limited to 'src/common/util.h')
-rw-r--r-- | src/common/util.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/common/util.h b/src/common/util.h index a9002254e7..f5e8deb661 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -356,14 +356,14 @@ void write_pidfile(char *filename); void tor_check_port_forwarding(const char *filename, int dir_port, int or_port, time_t now); -typedef struct process_handle_s process_handle_t; +typedef struct process_handle_t process_handle_t; int tor_spawn_background(const char *const filename, const char **argv, #ifdef MS_WINDOWS LPVOID envp, #else const char **envp, #endif - process_handle_t *process_handle); + process_handle_t **process_handle_out); #define SPAWN_ERROR_MESSAGE "ERR: Failed to spawn background process - code " @@ -377,7 +377,10 @@ HANDLE load_windows_system_library(const TCHAR *library_name); #define PROCESS_STATUS_NOTRUNNING 0 #define PROCESS_STATUS_RUNNING 1 #define PROCESS_STATUS_ERROR -1 -struct process_handle_s { + +#ifdef UTIL_PRIVATE +/*DOCDOC*/ +struct process_handle_t { int status; #ifdef MS_WINDOWS HANDLE stdout_pipe; @@ -391,12 +394,13 @@ struct process_handle_s { pid_t pid; #endif // MS_WINDOWS }; +#endif /* Return values of tor_get_exit_code() */ #define PROCESS_EXIT_RUNNING 1 #define PROCESS_EXIT_EXITED 0 #define PROCESS_EXIT_ERROR -1 -int tor_get_exit_code(const process_handle_t process_handle, +int tor_get_exit_code(const process_handle_t *process_handle, int block, int *exit_code); int tor_split_lines(struct smartlist_t *sl, char *buf, int len); #ifdef MS_WINDOWS @@ -414,6 +418,11 @@ ssize_t tor_read_all_from_process_stderr( char *tor_join_win_cmdline(const char *argv[]); int tor_process_get_pid(process_handle_t *process_handle); +#ifdef MS_WINDOWS +HANDLE tor_process_get_stdout_pipe(process_handle_t *process_handle); +#else +FILE *tor_process_get_stdout_pipe(process_handle_t *process_handle); +#endif int tor_terminate_process(process_handle_t *process_handle); void tor_process_handle_destroy(process_handle_t *process_handle, |