summaryrefslogtreecommitdiff
path: root/src/lib/process/process_unix.c
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2018-11-22 18:14:03 +0100
committerNick Mathewson <nickm@torproject.org>2018-12-17 16:39:28 -0500
commit338137221c8bd89f6d611c0cd3bf7b8a85d02517 (patch)
tree96eb8ee8c084a4ab9ece6ba06bbdc89300dccc32 /src/lib/process/process_unix.c
parente982fb1dae6ff0888ae419246578048470dd65b8 (diff)
downloadtor-338137221c8bd89f6d611c0cd3bf7b8a85d02517.tar.gz
tor-338137221c8bd89f6d611c0cd3bf7b8a85d02517.zip
Make sure we call process_notify_event_exit() as the last thing in different 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
Diffstat (limited to 'src/lib/process/process_unix.c')
-rw-r--r--src/lib/process/process_unix.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/process/process_unix.c b/src/lib/process/process_unix.c
index fa03fdbbe4..4f46bbd888 100644
--- a/src/lib/process/process_unix.c
+++ b/src/lib/process/process_unix.c
@@ -549,12 +549,16 @@ process_unix_waitpid_callback(int status, void *data)
process_t *process = data;
process_unix_t *unix_process = process_get_unix_process(process);
- /* Notify our process. */
- process_notify_event_exit(process, status);
-
/* Remove our waitpid callback. */
clear_waitpid_callback(unix_process->waitpid);
unix_process->waitpid = NULL;
+
+ /* Notify our process. */
+ process_notify_event_exit(process, status);
+
+ /* Make sure you don't modify the process after we have called
+ * process_notify_event_exit() on it, to allow users to process_free() it in
+ * the exit callback. */
}
/** This function sets the file descriptor in the <b>handle</b> as non-blocking