Chromium Code Reviews| Index: runtime/bin/process_win.cc |
| diff --git a/runtime/bin/process_win.cc b/runtime/bin/process_win.cc |
| index 00b51ed60a4e0d1628dfeeb2830f06f059651130..3e0803069883fb70b2150e8da202aad01b957f9f 100644 |
| --- a/runtime/bin/process_win.cc |
| +++ b/runtime/bin/process_win.cc |
| @@ -469,6 +469,8 @@ int Process::Start(const char* path, |
| char* arguments[], |
| intptr_t arguments_length, |
| const char* working_directory, |
| + char* environment[], |
| + intptr_t environment_length, |
| intptr_t* in, |
| intptr_t* out, |
| intptr_t* err, |
| @@ -585,6 +587,33 @@ int Process::Start(const char* path, |
| ASSERT(remaining >= 0); |
| } |
| + // Create environment block if an environment is supplied. |
| + char* environment_block = NULL; |
| + if (environment != NULL) { |
| + // An environment block is a sequence of zero-terminated strings |
| + // followed by a block-terminating zero char. |
| + intptr_t block_size = 1; |
| + for (intptr_t i = 0; i < environment_length; i++) { |
| + block_size += strlen(environment[i]) + 1; |
| + } |
| + environment_block = new char[block_size]; |
| + intptr_t block_index = 0; |
| + for (intptr_t i = 0; i < environment_length; i++) { |
| + printf("%s\n", environment[i]); |
|
Søren Gjesse
2012/04/19 12:45:55
Debugging print
Mads Ager (google)
2012/04/20 12:24:51
Removed.
|
| + intptr_t len = strlen(environment[i]); |
| + intptr_t result = snprintf(environment_block + block_index, |
| + len, |
| + "%s", |
| + environment[i]); |
| + ASSERT(result == len); |
| + block_index += len; |
| + environment_block[block_index++] = '\0'; |
| + } |
| + // Block-terminating zero char. |
| + environment_block[block_index++] = '\0'; |
| + ASSERT(block_index == block_size); |
| + } |
| + |
| // Create process. |
| BOOL result = CreateProcess(NULL, // ApplicationName |
| command_line, |
| @@ -592,13 +621,14 @@ int Process::Start(const char* path, |
| NULL, // ThreadAttributes |
| TRUE, // InheritHandles |
| 0, // CreationFlags |
| - NULL, // Environment |
| + environment_block, |
| working_directory, |
| &startup_info, |
| &process_info); |
| - // Deallocate command-line string. |
| + // Deallocate command-line and environment block strings. |
| delete[] command_line; |
| + delete[] environment_block; |
| if (result == 0) { |
| int error_code = SetOsErrorMessage(os_error_message, os_error_message_len); |