summaryrefslogtreecommitdiff
path: root/src/lib/process
AgeCommit message (Collapse)Author
2018-12-17Merge branch 'ticket28179_squashed' into ticket28179_squashed_mergedNick Mathewson
2018-12-17Ensure that line_size >= 1 before trying to trim input string.Alexander Færøy
See: https://bugs.torproject.org/28179
2018-12-17Make Windows process event timer API available for dormant interface.Alexander Færøy
This patch changes the API of the Windows backend of the Process subsystem to allow the dormant interface to disable the Process event timer. See: https://bugs.torproject.org/28179
2018-12-17Document the format of process_t::arguments.Alexander Færøy
See: https://bugs.torproject.org/28179
2018-12-17Use `const char *` instead of `char *` for line parameter for process callbacks.Alexander Færøy
This patch changes the type definition of the process callbacks to use `const char *` instead of `char *`. See: https://bugs.torproject.org/28179
2018-12-17Change the Process exit_callback to return bool.Alexander Færøy
This patch changes our process_t's exit_callback to return a boolean value. If the returned value is true, the process subsystem will call process_free() on the given process_t. See: https://bugs.torproject.org/28179
2018-12-17Call close() on stdin/stdout/stderr in process_terminate().Alexander Færøy
Call close() on all process handles after we have called kill(pid, SIGTERM). See: https://bugs.torproject.org/28179
2018-12-17Move remaining code from subprocess.{h,c} to more appropriate places.Alexander Færøy
This patch moves the remaining code from subprocess.{h,c} to more appropriate places in the process.c and process_win32.c module. We also delete the now empty subprocess module files. See: https://bugs.torproject.org/28179
2018-12-17Delete old process_handle_t code.Alexander Færøy
This patch removes the old process_handle_t code. Everything should by now be using the process_t interface. See: https://bugs.torproject.org/28179
2018-12-17Add process_reset_environment() to the Process subsystem.Alexander Færøy
This patch adds a new function that allows us to reset the environment of a given process_t with a list of key/value pairs. See: https://bugs.torproject.org/28179
2018-12-17Add process_terminate().Alexander Færøy
This patch adds support for process termination to the Process subsystem. See: https://bugs.torproject.org/28179
2018-12-17Make sure we call process_notify_event_exit() as the last thing in different ↵Alexander Færøy
callbacks. This patch makes sure that we call process_notify_event_exit() after we have done any modifications we need to do to the state of a process_t. This allows application developers to call process_free() in the exit_callback of the process. See: https://bugs.torproject.org/28179
2018-12-17Add process_get_pid() to the Process subsystem.Alexander Færøy
This patch adds support for getting the unique process identifier from a given process_t. This patch implements both support for both the Unix and Microsoft Windows backend. See: https://bugs.torproject.org/28179
2018-12-17Add Windows backend for the Process subsystem.Alexander Færøy
This patch adds support for Microsoft Windows in the Process subsystem. Libevent does not support mixing different types of handles (sockets, named pipes, etc.) on Windows in its core event loop code. This have historically meant that Tor have avoided attaching any non-networking handles to the event loop. This patch uses a slightly different approach to roughly support the same features for the Process subsystem as we do with the Unix backend. In this patch we use Windows Extended I/O functions (ReadFileEx() and WriteFileEx()) which executes asynchronously in the background and executes a completion routine when the scheduled read or write operation have completed. This is much different from the Unix backend where the operating system signals to us whenever a file descriptor is "ready" to either being read from or written to. To make the Windows operating system execute the completion routines of ReadFileEx() and WriteFileEx() we must get the Tor process into what Microsoft calls an "alertable" state. To do this we execute SleepEx() with a zero millisecond sleep time from a main loop timer that ticks once a second. This moves the process into the "alertable" state and when we return from the zero millisecond timeout all the outstanding I/O completion routines will be called and we can schedule the next reads and writes. The timer loop is also responsible for detecting whether our child processes have terminated since the last timer tick. See: https://bugs.torproject.org/28179
2018-12-17Add Unix backend for the Process subsystem.Alexander Færøy
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
2018-12-17Add new Process subsystem.Alexander Færøy
This patch adds a new Process subsystem for running external programs in the background of Tor. The design is focused around a new type named `process_t` which have an API that allows the developer to easily write code that interacts with the given child process. These interactions includes: - Easy API for writing output to the child process's standard input handle. - Receive callbacks whenever the child has output on either its standard output or standard error handles. - Receive callback when the child process terminates. We also support two different "protocols" for handling output from the child process. The default protocol is the "line" protocol where the process output callbacks will be invoked only when there is complete lines (either "\r\n" or "\n" terminated). We also support the "raw" protocol where the read callbacks will get whatever the operating system delivered to us in a single read operation. This patch does not include any operating system backends, but the Unix and Windows backends will be included in separate commits. See: https://bugs.torproject.org/28179
2018-11-14Normalize .may_include to always have paths, and paths to includeNick Mathewson
2018-11-09Rename subsystem callback functions to make them consistentNick Mathewson
2018-11-05Make the windows process parameter initialization a subsystemNick Mathewson
Also, move it from "main" into lib/process
2018-09-14Add a missing function for windowsNick Mathewson
2018-09-13Run crypto_prefork() before start_daemon().Nick Mathewson
Without this, RunAsDaemon breaks NSS. Fixes bug 27664; bug not in any released Tor.
2018-08-14Adjust windows stubs for new start/finish_daemon() return typesNick Mathewson
2018-08-08Call crypto_postfork on start_daemon() instead.Nick Mathewson
2018-08-08Make finish_daemon() return a boolean to say whether it did anything.Nick Mathewson
2018-07-10Rename torlog.[ch] to log.[ch]Nick Mathewson
Fun fact: these files used to be called log.[ch] until we ran into conflicts with systems having a log.h file. But now that we always include "lib/log/log.h", we should be fine.
2018-07-10Rename util_malloc to malloc.Nick Mathewson
2018-07-10File-level summary documentation for src/lib/*/*.[ch]Nick Mathewson
2018-07-01Prune the .may_include files a bit; detect unused lines in themNick Mathewson
2018-06-29Move fd and memory-info functions.Nick Mathewson
2018-06-28Fix macOS includesTaylor Yu
Recent code movement from refactoring missed some includes that seem to be necessary on macOS.
2018-06-28Add sys/capability.h and sys/prctl.h includes in setuid.cNick Mathewson
2018-06-28Extract process-management functionality into a new lib/processNick Mathewson
Note that procmon does *not* go here, since procmon needs to integrate with the event loop.