From: Nick Mathewson Date: Wed, 4 May 2016 19:10:36 +0000 (-0400) Subject: Report success when not terminating an already terminated process. X-Git-Tag: tor-0.2.8.3-alpha~45^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7b9e0b8ed7076525da185e25c2142b18b4d43e3;p=thirdparty%2Ftor.git Report success when not terminating an already terminated process. Also, document the actual behavior and return values of tor_terminate_process. Fixes bug18686; bugfix on 0.2.3.9-alpha. --- diff --git a/changes/bug18686 b/changes/bug18686 new file mode 100644 index 0000000000..23547d211d --- /dev/null +++ b/changes/bug18686 @@ -0,0 +1,5 @@ + o Minor bugfixes (pluggable transports): + - Avoid reporting a spurious error when we decide that we don't + need to terminate a pluggable transport because it has already + exited. Fixes bug 18686; bugfix on 0.2.5.5-alpha. + diff --git a/src/common/util.c b/src/common/util.c index 04cc6b12c6..65af8a672a 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -3626,8 +3626,13 @@ format_helper_exit_status(unsigned char child_state, int saved_errno, /* Maximum number of file descriptors, if we cannot get it via sysconf() */ #define DEFAULT_MAX_FD 256 -/** Terminate the process of process_handle. - * Code borrowed from Python's os.kill. */ +/** Terminate the process of process_handle, if that process has not + * already exited. + * + * Return 0 if we succeeded in terminating the process (or if the process + * already exited), and -1 if we tried to kill the process but failed. + * + * Based on code originally borrowed from Python's os.kill. */ int tor_terminate_process(process_handle_t *process_handle) { @@ -3647,7 +3652,7 @@ tor_terminate_process(process_handle_t *process_handle) } #endif - return -1; + return 0; /* We didn't need to kill the process, so report success */ } /** Return the Process ID of process_handle. */