Changes to process(4)

Changes to process:
commit 228297ec53e9ee7a1a6a3c5964ca7e89a6474c9b
Author: Herbert Valerio Riedel <hvr@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@gnu.org>

commit d95a67012ea30b02144d193254d947cdf5400a9d
Author: Duncan Coutts <duncan@community.haskell.org>
Date:   Tue Nov 26 00:04:41 2013 +0000

    Be even more careful with the threads that consume output (#2233)

    There is a potential deadlock with withCreateProcess in the case that
    there's an exception: cleanupProcess will try to hClose the various
    handles, but if another thread holds the Handle lock then that hClose
    will block.

    Takano Akio fixed the main case of this (in patch
    32223a9ab174c22e939c81e24b6f48223c7cb020) by terminating the process
    (before closing the handles) This works because terminating the process
    will eventually cause those other threads to finish and release the
    Handle lock, so we can hClose.

    However on Unix terminateProcess is not guaranteed to terminate the
    process since it uses SIGTERM, which can be handled or ignored. So we
    have to separately guarantee that the handles can be hClosed, and the
    simplest way to do this is to ensure that the thread reading from the
    handles get killed in the case there's an exception.

    So we change forkWait to withForkWait that will kill off the thread if
    the body gets an exception.

    Authored-by: Duncan Coutts <duncan@well-typed.com>
    Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>

commit 79ae975aab5866de38e1a01aca7ac5bd9cde2285
Author: Duncan Coutts <duncan@community.haskell.org>
Date:   Mon Nov 25 23:09:13 2013 +0000

    Improve the code for ignoring EPIPE (#2233)

    Factor it out into an ignoreSigPipe util, and use it in both
    readProcess and readProcessWithExitCode.

    Authored-by: Duncan Coutts <duncan@well-typed.com>
    Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>

commit b601209456e13ca3d08faffb7e6771bcb8c1b1b4
Author: Duncan Coutts <duncan@community.haskell.org>
Date:   Mon Nov 25 21:37:07 2013 +0000

    All new sync process functions now terminate on an exception (#2233)

    Now all the functions that call a process synchronously have the same
    behaviour. Previously just readProcess, readProcessWithExitCode did
    this, now callProcess and callCommand do too.

    If a thread running one of these functions gets an exception, including
    async exceptions (such as from timeout or killThread), then the
    external process gets terminated.

    Introduce a helper function to implement this behaviour. Currently it
    is not exposed to users, but that could be changed easily.

    Authored-by: Duncan Coutts <duncan@well-typed.com>
    Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>