[commit: packages/process] master: Drop redundant hFlush & add ignoreSigPipe to hClose (228297e)

git at git.haskell.org git at git.haskell.org
Sat Nov 30 23:03:39 UTC 2013


Repository : ssh://git@git.haskell.org/process

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/228297ec53e9ee7a1a6a3c5964ca7e89a6474c9b/process

>---------------------------------------------------------------

commit 228297ec53e9ee7a1a6a3c5964ca7e89a6474c9b
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Fri Nov 29 13:45:06 2013 +0100

    Drop redundant hFlush & add ignoreSigPipe to hClose
    
    This is a follow-up to 79ae975aab5866de38e1a01aca7ac5bd9cde2285
    (addressing #2233)
    
    Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>


>---------------------------------------------------------------

228297ec53e9ee7a1a6a3c5964ca7e89a6474c9b
 System/Process.hs |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/System/Process.hs b/System/Process.hs
index 581ef71..f8b0b7f 100644
--- a/System/Process.hs
+++ b/System/Process.hs
@@ -425,11 +425,11 @@ readProcess cmd args input = do
         output  <- hGetContents outh
         withForkWait (C.evaluate $ rnf output) $ \waitOut -> do
 
-          -- now write and flush any input
-          unless (null input) $ do
+          -- now write any input
+          unless (null input) $
             ignoreSigPipe $ hPutStr inh input
-            hFlush inh
-          hClose inh -- done with stdin
+          -- hClose performs implicit hFlush, and thus may trigger a SIGPIPE
+          ignoreSigPipe $ hClose inh
 
           -- wait on the output
           waitOut
@@ -484,11 +484,11 @@ readProcessWithExitCode cmd args input = do
         withForkWait  (C.evaluate $ rnf out) $ \waitOut ->
          withForkWait (C.evaluate $ rnf err) $ \waitErr -> do
 
-          -- now write and flush any input
-          unless (null input) $ do
+          -- now write any input
+          unless (null input) $
             ignoreSigPipe $ hPutStr inh input
-            hFlush inh
-          hClose inh
+          -- hClose performs implicit hFlush, and thus may trigger a SIGPIPE
+          ignoreSigPipe $ hClose inh
 
           -- wait on the output
           waitOut



More information about the ghc-commits mailing list