aboutsummaryrefslogtreecommitdiff
path: root/src/lib/process
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-12-21 13:26:47 -0500
committerNick Mathewson <nickm@torproject.org>2018-12-21 13:26:47 -0500
commitab4395d08206d82f69512340cf5372d5121561ad (patch)
treec693d3802b233ea039b584802b3aec5ffb6aa543 /src/lib/process
parent9190f43b1a9a6cb4eee02c6dc0a5fae17f9bfc59 (diff)
parentbc836d559dce5756f8ad2150d2351220ba7610f2 (diff)
downloadtor-ab4395d08206d82f69512340cf5372d5121561ad.tar.gz
tor-ab4395d08206d82f69512340cf5372d5121561ad.zip
Merge branch 'ticket28847'
Diffstat (limited to 'src/lib/process')
-rw-r--r--src/lib/process/include.am2
-rw-r--r--src/lib/process/process.h9
-rw-r--r--src/lib/process/process_sys.c33
-rw-r--r--src/lib/process/process_sys.h14
4 files changed, 55 insertions, 3 deletions
diff --git a/src/lib/process/include.am b/src/lib/process/include.am
index a2d54b6238..83b67bf029 100644
--- a/src/lib/process/include.am
+++ b/src/lib/process/include.am
@@ -10,6 +10,7 @@ src_lib_libtor_process_a_SOURCES = \
src/lib/process/env.c \
src/lib/process/pidfile.c \
src/lib/process/process.c \
+ src/lib/process/process_sys.c \
src/lib/process/process_unix.c \
src/lib/process/process_win32.c \
src/lib/process/restrict.c \
@@ -27,6 +28,7 @@ noinst_HEADERS += \
src/lib/process/env.h \
src/lib/process/pidfile.h \
src/lib/process/process.h \
+ src/lib/process/process_sys.h \
src/lib/process/process_unix.h \
src/lib/process/process_win32.h \
src/lib/process/restrict.h \
diff --git a/src/lib/process/process.h b/src/lib/process/process.h
index 179db19aeb..956d34ab29 100644
--- a/src/lib/process/process.h
+++ b/src/lib/process/process.h
@@ -47,6 +47,8 @@ const char *process_protocol_to_string(process_protocol_t protocol);
void tor_disable_spawning_background_processes(void);
+struct smartlist_t;
+
struct process_t;
typedef struct process_t process_t;
@@ -61,7 +63,7 @@ typedef bool
void process_init(void);
void process_free_all(void);
-const smartlist_t *process_get_all_processes(void);
+const struct smartlist_t *process_get_all_processes(void);
process_t *process_new(const char *command);
void process_free_(process_t *process);
@@ -82,10 +84,11 @@ void process_set_exit_callback(process_t *,
const char *process_get_command(const process_t *process);
void process_append_argument(process_t *process, const char *argument);
-const smartlist_t *process_get_arguments(const process_t *process);
+const struct smartlist_t *process_get_arguments(const process_t *process);
char **process_get_argv(const process_t *process);
-void process_reset_environment(process_t *process, const smartlist_t *env);
+void process_reset_environment(process_t *process,
+ const struct smartlist_t *env);
void process_set_environment(process_t *process,
const char *key,
const char *value);
diff --git a/src/lib/process/process_sys.c b/src/lib/process/process_sys.c
new file mode 100644
index 0000000000..a880ff146e
--- /dev/null
+++ b/src/lib/process/process_sys.c
@@ -0,0 +1,33 @@
+/* Copyright (c) 2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file process_sys.c
+ * \brief Subsystem object for process setup.
+ **/
+
+#include "orconfig.h"
+#include "lib/subsys/subsys.h"
+#include "lib/process/process_sys.h"
+#include "lib/process/process.h"
+
+static int
+subsys_process_initialize(void)
+{
+ process_init();
+ return 0;
+}
+
+static void
+subsys_process_shutdown(void)
+{
+ process_free_all();
+}
+
+const subsys_fns_t sys_process = {
+ .name = "process",
+ .level = -80,
+ .supported = true,
+ .initialize = subsys_process_initialize,
+ .shutdown = subsys_process_shutdown
+};
diff --git a/src/lib/process/process_sys.h b/src/lib/process/process_sys.h
new file mode 100644
index 0000000000..b299334b6b
--- /dev/null
+++ b/src/lib/process/process_sys.h
@@ -0,0 +1,14 @@
+/* Copyright (c) 2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file process_sys.h
+ * \brief Declare subsystem object for the process module.
+ **/
+
+#ifndef TOR_PROCESS_SYS_H
+#define TOR_PROCESS_SYS_H
+
+extern const struct subsys_fns_t sys_process;
+
+#endif /* !defined(TOR_PROCESS_SYS_H) */