diff options
author | Alexander Færøy <ahf@torproject.org> | 2018-11-22 04:43:27 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-12-17 16:39:28 -0500 |
commit | 2e957027e28449d4c3254cc404d154f4bce41bfc (patch) | |
tree | 2f04b258f5fbbe081c0e0f84ac8f0c8da5078504 /src/test | |
parent | 35509978dd4985901431abe895d1443e75afc00a (diff) | |
download | tor-2e957027e28449d4c3254cc404d154f4bce41bfc.tar.gz tor-2e957027e28449d4c3254cc404d154f4bce41bfc.zip |
Add Unix backend for the Process subsystem.
This patch adds the Unix backend for the Process subsystem. The Unix
backend attaches file descriptors from the child process's standard in,
out and error to Tor's libevent based main loop using traditional Unix
pipes. We use the already available `waitpid` module to get events
whenever the child process terminates.
See: https://bugs.torproject.org/28179
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_process.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/test_process.c b/src/test/test_process.c index 2adbde7ad2..816695ccab 100644 --- a/src/test/test_process.c +++ b/src/test/test_process.c @@ -12,6 +12,8 @@ #define PROCESS_PRIVATE #include "lib/process/process.h" +#define PROCESS_UNIX_PRIVATE +#include "lib/process/process_unix.h" static const char *stdout_read_buffer; static const char *stderr_read_buffer; @@ -544,6 +546,24 @@ test_argv_simple(void *arg) process_free_all(); } +static void +test_unix(void *arg) +{ + (void)arg; +#ifndef _WIN32 + process_init(); + + process_t *process = process_new(); + + /* On Unix all processes should have a Unix process handle. */ + tt_ptr_op(NULL, OP_NE, process_get_unix_process(process)); + + done: + process_free(process); + process_free_all(); +#endif +} + struct testcase_t process_tests[] = { { "default_values", test_default_values, TT_FORK, NULL, NULL }, { "stringified_types", test_stringified_types, TT_FORK, NULL, NULL }, @@ -554,5 +574,6 @@ struct testcase_t process_tests[] = { { "write_simple", test_write_simple, TT_FORK, NULL, NULL }, { "exit_simple", test_exit_simple, TT_FORK, NULL, NULL }, { "argv_simple", test_argv_simple, TT_FORK, NULL, NULL }, + { "unix", test_unix, TT_FORK, NULL, NULL }, END_OF_TESTCASES }; |