Skip to content

Commit

Permalink
(GH-818) Wait for processes to exit + 2 seconds
Browse files Browse the repository at this point in the history
There are cases when the process has signalled it has exited, but it
hasn't actually returned an exit code yet. Hold for 2 seconds to allow
the process to fully exit before attempting to capture the exit code.
  • Loading branch information
ferventcoder committed Jun 22, 2016
1 parent e2fa591 commit 575580d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ param(
Unregister-Event -SourceIdentifier "LogOutput_ChocolateyZipProc"
Unregister-Event -SourceIdentifier "LogErrors_ChocolateyZipProc"

# sometimes the process hasn't fully exited yet.
Start-Sleep 2

$exitCode = $process.ExitCode
Set-PowerShellExitCode $exitCode
$process.Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Elevating Permissions and running [`"$exeToRun`" $wrappedStatements]. This may t

$process = New-Object System.Diagnostics.Process
$process.EnableRaisingEvents = $true
Register-ObjectEvent -InputObject $process -SourceIdentifier "LogOutput_ChocolateyProc" -EventName OutputDataReceived -Action $writeOutput | Out-Null
Register-ObjectEvent -InputObject $process -SourceIdentifier "LogOutput_ChocolateyProc" -EventName OutputDataReceived -Action $writeOutput | Out-Null
Register-ObjectEvent -InputObject $process -SourceIdentifier "LogErrors_ChocolateyProc" -EventName ErrorDataReceived -Action $writeError | Out-Null

#$process.StartInfo = New-Object System.Diagnostics.ProcessStartInfo($exeToRun, $wrappedStatements)
Expand Down Expand Up @@ -191,6 +191,9 @@ Elevating Permissions and running [`"$exeToRun`" $wrappedStatements]. This may t
# them to do so. Without this it never finishes.
Unregister-Event -SourceIdentifier "LogOutput_ChocolateyProc"
Unregister-Event -SourceIdentifier "LogErrors_ChocolateyProc"

# sometimes the process hasn't fully exited yet.
Start-Sleep 2

$exitCode = $process.ExitCode
$process.Dispose()
Expand Down

0 comments on commit 575580d

Please sign in to comment.