@@ -434,22 +434,29 @@ let asyncShellExec (args : ExecParams) =
434
434
let info =
435
435
ProcessStartInfo
436
436
( args.Program, UseShellExecute = false ,
437
- RedirectStandardError = true , RedirectStandardOutput = true , RedirectStandardInput = true ,
438
- WindowStyle = ProcessWindowStyle.Hidden, WorkingDirectory = args.WorkingDirectory,
439
- Arguments = commandLine)
440
- use proc = new Process( StartInfo = info)
441
- proc.ErrorDataReceived.Add( fun e ->
442
- if e.Data <> null then traceError e.Data)
443
- proc.OutputDataReceived.Add( fun e ->
444
- if e.Data <> null then log e.Data)
445
- start proc
446
- proc.BeginOutputReadLine()
447
- proc.BeginErrorReadLine()
448
- proc.StandardInput.Close()
449
- // attaches handler to Exited event, enables raising events, then awaits event
450
- // the event gets triggered even if process has already finished
451
- let! _ = Async.GuardedAwaitObservable proc.Exited ( fun _ -> proc.EnableRaisingEvents <- true )
452
- return proc.ExitCode
437
+ RedirectStandardError = true , RedirectStandardOutput = true , RedirectStandardInput = true ,
438
+ WindowStyle = ProcessWindowStyle.Hidden, WorkingDirectory = args.WorkingDirectory,
439
+ Arguments = commandLine)
440
+ let proc = new Process( StartInfo = info)
441
+
442
+ try
443
+ proc.ErrorDataReceived.Add( fun e ->
444
+ if e.Data <> null then traceError e.Data)
445
+ proc.OutputDataReceived.Add( fun e ->
446
+ if e.Data <> null then log e.Data)
447
+ start proc
448
+ proc.BeginOutputReadLine()
449
+ proc.BeginErrorReadLine()
450
+ proc.StandardInput.Close()
451
+ // attaches handler to Exited event, enables raising events, then awaits event
452
+ // the event gets triggered even if process has already finished
453
+ let! _ = Async.GuardedAwaitObservable proc.Exited ( fun _ -> proc.EnableRaisingEvents <- true )
454
+ return proc.ExitCode
455
+ finally
456
+ // add a delay because we were seeing ObjectDisposedException when running shell commands on
457
+ // osx. Github issue #1424.
458
+ Async.Sleep ( 10 ) |> Async.RunSynchronously
459
+ proc.Dispose()
453
460
}
454
461
455
462
/// Kills the given process
0 commit comments