[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Pass process_environment_t * to tor_spawn_background
commit c0808b795f9b52184a18e7a2960f56ed0e330c4b
Author: Robert Ransom <rransom.8774@xxxxxxxxx>
Date: Mon Feb 13 00:59:49 2012 -0800
Pass process_environment_t * to tor_spawn_background
Now tor_spawn_background's prototype is OS-independent.
---
src/common/util.c | 12 ++++--------
src/common/util.h | 15 ++++-----------
src/or/transports.c | 4 ++--
3 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/src/common/util.c b/src/common/util.c
index ac65f48..90ad8c0 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -3313,11 +3313,7 @@ process_handle_new(void)
*/
int
tor_spawn_background(const char *const filename, const char **argv,
-#ifdef _WIN32
- LPVOID envp,
-#else
- const char **envp,
-#endif
+ process_environment_t *env,
process_handle_t **process_handle_out)
{
#ifdef _WIN32
@@ -3398,7 +3394,7 @@ tor_spawn_background(const char *const filename, const char **argv,
/*(TODO: set CREATE_NEW CONSOLE/PROCESS_GROUP to make GetExitCodeProcess()
* work?) */
0, // creation flags
- envp, // use parent's environment
+ (env==NULL) ? NULL : env->windows_environment_block,
NULL, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&(process_handle->pid)); // receives PROCESS_INFORMATION
@@ -3528,8 +3524,8 @@ tor_spawn_background(const char *const filename, const char **argv,
/* Call the requested program. We need the cast because
execvp doesn't define argv as const, even though it
does not modify the arguments */
- if (envp)
- execve(filename, (char *const *) argv, (char*const*)envp);
+ if (env)
+ execve(filename, (char *const *) argv, env->unixoid_environment_block);
else
execvp(filename, (char *const *) argv);
diff --git a/src/common/util.h b/src/common/util.h
index 41bd3d9..567efaa 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -365,12 +365,9 @@ void tor_check_port_forwarding(const char *filename,
int dir_port, int or_port, time_t now);
typedef struct process_handle_t process_handle_t;
+typedef struct process_environment_t process_environment_t;
int tor_spawn_background(const char *const filename, const char **argv,
-#ifdef _WIN32
- LPVOID envp,
-#else
- const char **envp,
-#endif
+ process_environment_t *env,
process_handle_t **process_handle_out);
#define SPAWN_ERROR_MESSAGE "ERR: Failed to spawn background process - code "
@@ -386,13 +383,9 @@ struct process_environment_t {
* NUL-terminated strings of the form "NAME=VALUE". */
char *windows_environment_block;
/** A pointer to a NULL-terminated array of pointers to
- * NUL-terminated strings of the form "NAME=VALUE".
- *
- * XXXX This should have type char **, but tor_spawn_background's
- * prototype is incorrect. */
- const char **unixoid_environment_block;
+ * NUL-terminated strings of the form "NAME=VALUE". */
+ char **unixoid_environment_block;
};
-typedef struct process_environment_t process_environment_t;
process_environment_t *process_environment_make(struct smartlist_t *env_vars);
void process_environment_free(process_environment_t *env);
diff --git a/src/or/transports.c b/src/or/transports.c
index b3c8382..c10490e 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -288,12 +288,12 @@ launch_managed_proxy(managed_proxy_t *mp)
/* Passing NULL as lpApplicationName makes Windows search for the .exe */
retval = tor_spawn_background(NULL,
(const char **)mp->argv,
- env->windows_environment_block,
+ env,
&mp->process_handle);
#else
retval = tor_spawn_background(mp->argv[0],
(const char **)mp->argv,
- env->unixoid_environment_block,
+ env,
&mp->process_handle);
#endif
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits