about summary refs log tree commit diff
path: root/x.ps1
diff options
context:
space:
mode:
Diffstat (limited to 'x.ps1')
-rwxr-xr-xx.ps17
1 files changed, 7 insertions, 0 deletions
diff --git a/x.ps1 b/x.ps1
index f324a4676c8..b0cddc9f930 100755
--- a/x.ps1
+++ b/x.ps1
@@ -16,7 +16,14 @@ function Get-Application($app) {
 
 function Invoke-Application($application, $arguments) {
     $process = Start-Process -NoNewWindow -PassThru $application $arguments
+    # WORKAROUND: Caching the handle is necessary to make ExitCode work.
+    # See https://stackoverflow.com/a/23797762
+    $handle = $process.Handle
     $process.WaitForExit()
+    if ($null -eq $process.ExitCode) {
+        Write-Error "Unable to read the exit code"
+        Exit 1
+    }
     Exit $process.ExitCode
 }