summaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorSteven Murdoch <Steven.Murdoch@cl.cam.ac.uk>2011-07-21 16:34:48 +0100
committerSteven Murdoch <Steven.Murdoch@cl.cam.ac.uk>2011-07-21 16:34:48 +0100
commit35c89be02b535e2951b695429bd9b255afb2a7b2 (patch)
tree292e9a1ce5d885d4144c90a457e82412676da18e /src/common/util.h
parent2002d4acdfac823c03cca3ed92de7f60b3272d86 (diff)
downloadtor-35c89be02b535e2951b695429bd9b255afb2a7b2.tar.gz
tor-35c89be02b535e2951b695429bd9b255afb2a7b2.zip
Generalize process spawning so its test compiles (but fails) in Windows
- pid, stdout/stderr_pipe now encapsulated in process_handle - read_all replaced by tor_read_all_from_process_stdin/stderr - waitpid replaced by tor_get_exit_code Untested on *nix
Diffstat (limited to 'src/common/util.h')
-rw-r--r--src/common/util.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/common/util.h b/src/common/util.h
index 6496c42db8..2cf57a125d 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -347,8 +347,27 @@ HANDLE load_windows_system_library(const TCHAR *library_name);
#ifdef UTIL_PRIVATE
/* Prototypes for private functions only used by util.c (and unit tests) */
-int tor_spawn_background(const char *const filename, int *stdout_read,
- int *stderr_read, const char **argv);
+
+typedef struct process_handle_s {
+ int status;
+#ifdef MS_WINDOWS
+ HANDLE stdout_pipe;
+ HANDLE stderr_pipe;
+ HANDLE pid;
+#else
+ int stdout_pipe;
+ int stderr_pipe;
+ int pid;
+#endif // MS_WINDOWS
+} process_handle_t;
+
+process_handle_t tor_spawn_background(const char *const filename,
+ const char **argv);
+int tor_get_exit_code(const process_handle_t pid);
+ssize_t tor_read_all_from_process_stdin(const process_handle_t process_handle,
+ char *buf, size_t count);
+ssize_t tor_read_all_from_process_stderr(const process_handle_t process_handle,
+ char *buf, size_t count);
void format_helper_exit_status(unsigned char child_state,
int saved_errno, char *hex_errno);