summaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-04-10 11:06:10 -0400
committerNick Mathewson <nickm@torproject.org>2014-06-14 11:40:27 -0400
commitf8344c2d28be2489c8abadd694b5b96fe18efc02 (patch)
tree8c3e5d2663d6d2f37476d915ad47d41906007f1d /src/common/util.h
parent4ed03965a5a412bf58540e678f48f6c331ad30d9 (diff)
downloadtor-f8344c2d28be2489c8abadd694b5b96fe18efc02.tar.gz
tor-f8344c2d28be2489c8abadd694b5b96fe18efc02.zip
Use waitpid code to learn when a controlled process dies
This lets us avoid sending SIGTERM to something that has already died, since we realize it has already died, and is a fix for the unix version of #8746.
Diffstat (limited to 'src/common/util.h')
-rw-r--r--src/common/util.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/common/util.h b/src/common/util.h
index 18dc20639f..97367a9a7b 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -446,6 +446,7 @@ void set_environment_variable_in_smartlist(struct smartlist_t *env_vars,
#define PROCESS_STATUS_ERROR -1
#ifdef UTIL_PRIVATE
+struct waitpid_callback_t;
/** Structure to represent the state of a process with which Tor is
* communicating. The contents of this structure are private to util.c */
struct process_handle_t {
@@ -461,6 +462,12 @@ struct process_handle_t {
FILE *stdout_handle;
FILE *stderr_handle;
pid_t pid;
+ /** If the process has not given us a SIGCHLD yet, this has the
+ * waitpid_callback_t that gets invoked once it has. Otherwise this
+ * contains NULL. */
+ struct waitpid_callback_t *waitpid_cb;
+ /** The exit status reported by waitpid. */
+ int waitpid_exit_status;
#endif // _WIN32
};
#endif
@@ -469,7 +476,7 @@ struct process_handle_t {
#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(process_handle_t *process_handle,
int block, int *exit_code);
int tor_split_lines(struct smartlist_t *sl, char *buf, int len);
#ifdef _WIN32