diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-10-18 12:32:49 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-10-18 12:32:49 -0400 |
commit | 264c5312eb7fc70b092b22ec978c1b400b7fd826 (patch) | |
tree | c562de3e184126370deceb4b40382d092453df36 /src/lib/process | |
parent | 7c5716d162f2109f246fbd369185c973dd60b22b (diff) | |
parent | 0994050c4a766fad94ce5108e99d18b0a6200e5f (diff) | |
download | tor-264c5312eb7fc70b092b22ec978c1b400b7fd826.tar.gz tor-264c5312eb7fc70b092b22ec978c1b400b7fd826.zip |
Merge branch 'maint-0.4.2'
Diffstat (limited to 'src/lib/process')
-rw-r--r-- | src/lib/process/process_unix.c | 9 | ||||
-rw-r--r-- | src/lib/process/process_win32.c | 18 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/lib/process/process_unix.c b/src/lib/process/process_unix.c index 332b432c54..8191bdc1f0 100644 --- a/src/lib/process/process_unix.c +++ b/src/lib/process/process_unix.c @@ -253,22 +253,15 @@ process_unix_exec(process_t *process) process_environment_t *env = process_get_environment(process); /* Call the requested program. */ - retval = execve(argv[0], argv, env->unixoid_environment_block); + execve(argv[0], argv, env->unixoid_environment_block); /* If we made it here it is because execve failed :-( */ - if (-1 == retval) - fprintf(stderr, "Call to execve() failed: %s", strerror(errno)); - tor_free(argv); process_environment_free(env); - tor_assert_unreached(); - error: - /* LCOV_EXCL_START */ fprintf(stderr, "Error from child process: %s", strerror(errno)); _exit(1); - /* LCOV_EXCL_STOP */ } /* We are in the parent process. */ 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; } |