message: [vcpkg-edit] Don't launch the editor in a clean environment
diff: @@ -117,10 +117,7 @@ namespace vcpkg::System
  }
  #if defined(_WIN32)
  - static void windows_create_clean_process(const CStringView cmd_line,
  - const std::unordered_map<std::string, std::string>& extra_env,
  - PROCESS_INFORMATION& process_info,
  - DWORD dwCreationFlags) noexcept
  + static std::wstring compute_clean_environment(const std::unordered_map<std::string, std::string>& extra_env)
  {
  static const std::string SYSTEM_ROOT = get_environment_variable("SystemRoot").value_or_exit(VCPKG_LINE_INFO);
  static const std::string SYSTEM_32 = SYSTEM_ROOT + R"(\system32)";
  @@ -173,9 +170,6 @@ namespace vcpkg::System
  L"NVCUDASAMPLES_ROOT",
  };
  - // Flush stdout before launching external process
  - fflush(nullptr);
  -
  std::wstring env_cstr;
  for (auto&& env_wstring : env_wstrings)
  @@ -206,10 +200,27 @@ namespace vcpkg::System
  env_cstr.push_back(L'\0');
  }
  + return env_cstr;
  + }
  +#endif
  +
  +#if defined(_WIN32)
  + /// <param name="maybe_environment">If non-null, an environment block to use for the new process. If null, the new
  + /// process will inherit the current environment.</param>
  + static void windows_create_process(const CStringView cmd_line,
  + const wchar_t* maybe_environment,
  + DWORD dwCreationFlags,
  + PROCESS_INFORMATION* process_info) noexcept
  + {
  + Checks::check_exit(VCPKG_LINE_INFO, process_info != nullptr);
  +
  STARTUPINFOW startup_info;
  memset(&startup_info, 0, sizeof(STARTUPINFOW));
  startup_info.cb = sizeof(STARTUPINFOW);
  + // Flush stdout before launching external process
  + fflush(nullptr);
  +
  // Wrapping the command in a single set of quotes causes cmd.exe to correctly execute
  const std::string actual_cmd_line = Strings::format(R"###(cmd.exe /c "%s")###", cmd_line);
  Debug::println("CreateProcessW(%s)", actual_cmd_line);
  @@ -219,10 +230,10 @@ namespace vcpkg::System
  nullptr,
  FALSE,
  IDLE_PRIORITY_CLASS | CREATE_UNICODE_ENVIRONMENT | dwCreationFlags,
  - env_cstr.data(),
  + (void*)maybe_environment,
  nullptr,
  &startup_info,
  - &process_info);
  + process_info);
  Checks::check_exit(VCPKG_LINE_INFO, succeeded, "Process creation failed with error code: %lu", GetLastError());
  }
  @@ -236,7 +247,7 @@ namespace vcpkg::System
  PROCESS_INFORMATION process_info;
  memset(&process_info, 0, sizeof(PROCESS_INFORMATION));
  - windows_create_clean_process(cmd_line, {}, process_info, DETACHED_PROCESS);
  + windows_create_process(cmd_line, nullptr, DETACHED_PROCESS, &process_info);
  CloseHandle(process_info.hThread);
  CloseHandle(process_info.hProcess);
  @@ -255,7 +266,8 @@ namespace vcpkg::System
  memset(&process_info, 0, sizeof(PROCESS_INFORMATION));
  GlobalState::g_ctrl_c_state.transition_to_spawn_process();
  - windows_create_clean_process(cmd_line, extra_env, process_info, NULL);
  + auto clean_env = compute_clean_environment(extra_env);
  + windows_create_process(cmd_line, clean_env.c_str(), NULL, &process_info);
  CloseHandle(process_info.hThread);
  