Skip to content

Commit

Permalink
(chocolatey-archiveGH-571) Use process id instead of name
Browse files Browse the repository at this point in the history
When waiting for a process to exit, use the id of the process as name may cause
errors if the name if is incorrect versus the actual process name. ID is
deterministic so should have less chance for error.
  • Loading branch information
ferventcoder committed Nov 2, 2014
1 parent c2d2261 commit d6068c2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/functions/Chocolatey-Pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ param(

$process = Start-Process $nugetExe -ArgumentList $packageArgs -NoNewWindow -Wait -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile -PassThru
# this is here for specific cases in Posh v3 where -Wait is not honored
try { if (!($process.HasExited)) { Wait-Process $process } } catch { }
try { if (!($process.HasExited)) { Wait-Process -Id $process.Id } } catch { }

$nugetOutput = Get-Content $logFile -Encoding Ascii
foreach ($line in $nugetOutput) {
Expand Down
2 changes: 1 addition & 1 deletion src/functions/Chocolatey-Push.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ param(

$process = Start-Process $nugetExe -ArgumentList $packageArgs -NoNewWindow -Wait -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile -PassThru
# this is here for specific cases in Posh v3 where -Wait is not honored
try { if (!($process.HasExited)) { Wait-Process $process } } catch { }
try { if (!($process.HasExited)) { Wait-Process -Id $process.Id } } catch { }

$nugetOutput = Get-Content $logFile -Encoding Ascii
foreach ($line in $nugetOutput) {
Expand Down
2 changes: 1 addition & 1 deletion src/functions/Chocolatey-Python.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ param(
Write-Host "Opening minimized PowerShell window and calling `'cmd.exe $packageArgs`'. If progress is taking a long time, please check that window. It also may not be 100% silent..." -ForegroundColor $Warning -BackgroundColor Black
$process = Start-Process -FilePath "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy unrestricted -Command `"cmd.exe $packageArgs | Tee-Object -FilePath `'$chocoInstallLog`'`"" -Wait -WindowStyle Minimized -PassThru
# this is here for specific cases in Posh v3 where -Wait is not honored
try { if (!($process.HasExited)) { Wait-Process $process } } catch { }
try { if (!($process.HasExited)) { Wait-Process -Id $process.Id } } catch { }

Create-InstallLogIfNotExists $chocoInstallLog
$installOutput = Get-Content $chocoInstallLog -Encoding Ascii
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/functions/Get-CheckSumValid.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ param(
Write-Debug "Calling command [`'$checksumExe`' -c$checksum `"$file`"] to retrieve checksum"
$process = Start-Process "$checksumExe" -ArgumentList " -c=`"$checksum`" -t=`"$checksumType`" -f=`"$file`"" -Wait -WindowStyle Hidden -PassThru
# this is here for specific cases in Posh v3 where -Wait is not honored
try { if (!($process.HasExited)) { Wait-Process $process } } catch { }
try { if (!($process.HasExited)) { Wait-Process -Id $process.Id } } catch { }

Write-Debug "`'$checksumExe`' exited with $($process.ExitCode)"

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/functions/Get-ChocolateyUnzip.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ param(
param($7zip, $destination, $fileFullPath, [ref]$exitCodeRef)
$process = Start-Process $7zip -ArgumentList "x -o`"$destination`" -y `"$fileFullPath`"" -Wait -WindowStyle Hidden -PassThru
# this is here for specific cases in Posh v3 where -Wait is not honored
try { if (!($process.HasExited)) { Wait-Process $process } } catch { }
try { if (!($process.HasExited)) { Wait-Process -Id $process.Id } } catch { }

$exitCodeRef.Value = $process.ExitCode
}
Expand Down

0 comments on commit d6068c2

Please sign in to comment.