diff options
author | Alexander Færøy <ahf@torproject.org> | 2019-10-17 16:47:04 +0200 |
---|---|---|
committer | Alexander Færøy <ahf@torproject.org> | 2019-10-17 20:52:27 +0200 |
commit | 7a64f6ea049747385acf77985ad4df5fa497b3e1 (patch) | |
tree | 158105a6fc7d4ec1ebb3730f47378647e7d50933 /src/lib/process | |
parent | 85b4a5c27659a7d162c2e476e1e0dfbeefd73095 (diff) | |
download | tor-7a64f6ea049747385acf77985ad4df5fa497b3e1.tar.gz tor-7a64f6ea049747385acf77985ad4df5fa497b3e1.zip |
Ensure that the exit callback is called if CreateProcessA() fails on Windows.
This patch fixes an issue where the exit handler is not called for the
given process_t in case CreateProcessA() fails. This could, for example,
happen if the user tries to execute a binary that does not exist.
See: https://bugs.torproject.org/31810
Diffstat (limited to 'src/lib/process')
-rw-r--r-- | src/lib/process/process_win32.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/process/process_win32.c b/src/lib/process/process_win32.c index 624333d4a3..7e4082ad13 100644 --- a/src/lib/process/process_win32.c +++ b/src/lib/process/process_win32.c @@ -234,6 +234,24 @@ process_win32_exec(process_t *process) CloseHandle(stdin_pipe_read); CloseHandle(stdin_pipe_write); + /* In the Unix backend, we do not get an error in the Tor process when a + * child process fails to spawn its target executable since we need to + * first do the fork() call in the Tor process and then the child process + * is responsible for doing the call to execve(). + * + * This means that the user of the process_exec() API must check for + * whether it returns PROCESS_STATUS_ERROR, which will rarely happen on + * Unix, but will happen for error cases on Windows where it does not + * happen on Unix. For example: when the target executable does not exist + * on the file system. + * + * To have somewhat feature compatibility between the Unix and the Windows + * backend, we here notify the process_t owner that the process have exited + * (even though it never managed to run) to ensure that the exit callback + * is executed. + */ + process_notify_event_exit(process, 0); + return PROCESS_STATUS_ERROR; } |