@@ -676,14 +676,16 @@ getCurrentPid =
676
676
-- waitForProcess
677
677
678
678
{- | Waits for the specified process to terminate, and returns its exit code.
679
+ On Unix systems, may throw 'UserInterrupt' when using 'delegate_ctlc'.
679
680
680
681
GHC Note: in order to call @waitForProcess@ without blocking all the
681
682
other threads in the system, you must compile the program with
682
683
@-threaded@.
683
684
684
685
Note that it is safe to call @waitForProcess@ for the same process in multiple
685
686
threads. When the process ends, threads blocking on this call will wake in
686
- FIFO order.
687
+ FIFO order. When using 'delegate_ctlc' and the process is interrupted, only
688
+ the first waiting thread will throw 'UserInterrupt'.
687
689
688
690
(/Since: 1.2.0.0/) On Unix systems, a negative value @'ExitFailure' -/signum/@
689
691
indicates that the child was terminated by signal @/signum/@.
@@ -710,6 +712,8 @@ waitForProcess ph@(ProcessHandle _ delegating_ctlc _) = lockWaitpid $ do
710
712
OpenHandle ph' -> do
711
713
closePHANDLE ph'
712
714
return (ClosedHandle e, (e, True ))
715
+ -- endDelegateControlC after closing the handle, since it
716
+ -- may throw UserInterrupt
713
717
when (was_open && delegating_ctlc) $
714
718
endDelegateControlC e
715
719
return e'
@@ -759,7 +763,8 @@ still running, 'Nothing' is returned. If the process has exited, then
759
763
@'Just' e@ is returned where @e@ is the exit code of the process.
760
764
761
765
On Unix systems, see 'waitForProcess' for the meaning of exit codes
762
- when the process died as the result of a signal.
766
+ when the process died as the result of a signal. May throw
767
+ 'UserInterrupt' when using 'delegate_ctlc'.
763
768
-}
764
769
765
770
getProcessExitCode :: ProcessHandle -> IO (Maybe ExitCode )
@@ -782,6 +787,8 @@ getProcessExitCode ph@(ProcessHandle _ delegating_ctlc _) = tryLockWaitpid $ do
782
787
let e | code == 0 = ExitSuccess
783
788
| otherwise = ExitFailure (fromIntegral code)
784
789
return (ClosedHandle e, (Just e, True ))
790
+ -- endDelegateControlC after closing the handle, since it
791
+ -- may throw UserInterrupt
785
792
case m_e of
786
793
Just e | was_open && delegating_ctlc -> endDelegateControlC e
787
794
_ -> return ()
0 commit comments