Don't inherit the same handle more than once. (#1234)
This commit is contained in:
Родитель
f40f40c912
Коммит
bad6195742
|
@ -1,5 +1,6 @@
|
|||
. $PSScriptRoot/../end-to-end-tests-prelude.ps1
|
||||
|
||||
Refresh-TestRoot
|
||||
$out = Join-Path $TestingRoot "a-tar-with-execute"
|
||||
Run-Vcpkg z-extract "$PSScriptRoot/../e2e-assets/extract/a-tar-with-plus-x.tar.gz" $out
|
||||
Throw-IfFailed
|
||||
|
@ -15,3 +16,28 @@ if (-Not $IsWindows) {
|
|||
throw "File does not have +x permission. UnixMode: $unixMode"
|
||||
}
|
||||
}
|
||||
|
||||
# Regression test for https://github.com/microsoft/vcpkg/issues/33904 / https://github.com/microsoft/vcpkg-tool/pull/1234
|
||||
if ($IsWindows) {
|
||||
Refresh-TestRoot
|
||||
$gitCommand = Get-Command git
|
||||
$gitDirectory = (Get-Item $gitCommand.Source).Directory
|
||||
$bash = "$gitDirectory/bash.exe"
|
||||
if (-Not (Test-Path $bash)) {
|
||||
$gitInstallation = $gitDirectory.Parent
|
||||
$bash = "$gitInstallation/bin/bash.exe"
|
||||
if (-Not (Test-Path $bash)) {
|
||||
throw 'git bash not found'
|
||||
}
|
||||
}
|
||||
|
||||
$out = Join-Path $TestingRoot "a-tar-with-execute"
|
||||
[string]$vcpkgExeForwardSlashes = $vcpkgExe.Replace("\", "/")
|
||||
[string]$tarballForwardSlashes = "$PSScriptRoot/../e2e-assets/extract/a-tar-with-plus-x.tar.gz".Replace("\", "/")
|
||||
[string]$outForwardSlashes = $out.Replace("\", "/")
|
||||
& $bash -c "`"$vcpkgExeForwardSlashes`" z-extract `"$tarballForwardSlashes`" `"$outForwardSlashes`""
|
||||
$extractedFilePath = Join-Path $out "myExe"
|
||||
if (-Not (Test-Path $extractedFilePath)) {
|
||||
throw "Extraction Failed"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1380,10 +1380,15 @@ namespace vcpkg
|
|||
return std::move(proc_attribute_list_create).error();
|
||||
}
|
||||
|
||||
HANDLE handles_to_inherit[] = {
|
||||
constexpr size_t number_of_candidate_handles = 3;
|
||||
HANDLE handles_to_inherit[number_of_candidate_handles] = {
|
||||
GetStdHandle(STD_INPUT_HANDLE), GetStdHandle(STD_OUTPUT_HANDLE), GetStdHandle(STD_ERROR_HANDLE)};
|
||||
Util::sort(handles_to_inherit);
|
||||
size_t number_of_handles =
|
||||
std::unique(handles_to_inherit, handles_to_inherit + number_of_candidate_handles) - handles_to_inherit;
|
||||
|
||||
auto maybe_error = proc_attribute_list.update_attribute(
|
||||
PROC_THREAD_ATTRIBUTE_HANDLE_LIST, handles_to_inherit, 3 * sizeof(HANDLE));
|
||||
PROC_THREAD_ATTRIBUTE_HANDLE_LIST, handles_to_inherit, number_of_handles * sizeof(HANDLE));
|
||||
if (!maybe_error.has_value())
|
||||
{
|
||||
return maybe_error.error();
|
||||
|
|
|
@ -905,6 +905,22 @@ namespace vcpkg
|
|||
|
||||
ExpectedL<Path> find_system_tar(const ReadOnlyFilesystem& fs)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
const auto& maybe_system32 = get_system32();
|
||||
if (auto system32 = maybe_system32.get())
|
||||
{
|
||||
auto shipped_with_windows = *system32 / "tar.exe";
|
||||
if (fs.is_regular_file(shipped_with_windows))
|
||||
{
|
||||
return shipped_with_windows;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return maybe_system32.error();
|
||||
}
|
||||
#endif // ^^^ _WIN32
|
||||
|
||||
const auto tools = fs.find_from_PATH(Tools::TAR);
|
||||
if (tools.empty())
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче