Commit 9a4983bd authored by Daniel Brooks's avatar Daniel Brooks
Browse files

Merge remote-tracking branch 'haskell/master' into HEAD

parents 58d7e5b9 bb01985d
......@@ -91,7 +91,6 @@ import System.IO.Error (mkIOError, ioeSetErrorString)
# include <io.h> /* for _close and _pipe */
# include <fcntl.h> /* for _O_BINARY */
import Control.Exception (onException)
import Foreign.C.Types (CInt(..), CUInt(..))
#else
import System.Posix.Process (getProcessGroupIDOf)
import qualified System.Posix.IO as Posix
......
......@@ -230,6 +230,7 @@ data StdStream
-- @Handle@ will use the default encoding
-- and newline translation mode (just
-- like @Handle@s created by @openFile@).
| NoStream -- ^ No stream handle will be passed
-- | This function is almost identical to
-- 'System.Process.createProcess'. The only differences are:
......@@ -517,6 +518,7 @@ fd_stderr = 2
mbFd :: String -> FD -> StdStream -> IO FD
mbFd _ _std CreatePipe = return (-1)
mbFd _fun std Inherit = return std
mbFd _fn _std NoStream = return (-2)
mbFd fun _std (UseHandle hdl) =
withHandle fun hdl $ \Handle__{haDevice=dev,..} ->
case cast dev of
......
......@@ -165,6 +165,8 @@ runInteractiveProcess (char *const args[],
close(fdStdInput[0]);
}
close(fdStdInput[1]);
} else if (fdStdIn == -2) {
close(STDIN_FILENO);
} else {
dup2(fdStdIn, STDIN_FILENO);
}
......@@ -175,6 +177,8 @@ runInteractiveProcess (char *const args[],
close(fdStdOutput[1]);
}
close(fdStdOutput[0]);
} else if (fdStdOut == -2) {
close(STDOUT_FILENO);
} else {
dup2(fdStdOut, STDOUT_FILENO);
}
......@@ -185,6 +189,8 @@ runInteractiveProcess (char *const args[],
close(fdStdError[1]);
}
close(fdStdError[0]);
} else if (fdStdErr == -2) {
close(STDERR_FILENO);
} else {
dup2(fdStdErr, STDERR_FILENO);
}
......@@ -484,6 +490,8 @@ runInteractiveProcess (wchar_t *cmd, wchar_t *workingDirectory,
if (!mkAnonPipe(&hStdInputRead, TRUE, &hStdInputWrite, FALSE))
goto cleanup_err;
sInfo.hStdInput = hStdInputRead;
} else if (fdStdIn == -2) {
sInfo.hStdInput = NULL;
} else if (fdStdIn == 0) {
// Don't duplicate stdin, as console handles cannot be
// duplicated and inherited. urg.
......@@ -504,6 +512,8 @@ runInteractiveProcess (wchar_t *cmd, wchar_t *workingDirectory,
if (!mkAnonPipe(&hStdOutputRead, FALSE, &hStdOutputWrite, TRUE))
goto cleanup_err;
sInfo.hStdOutput = hStdOutputWrite;
} else if (fdStdOut == -2) {
sInfo.hStdOutput = NULL;
} else if (fdStdOut == 1) {
// Don't duplicate stdout, as console handles cannot be
// duplicated and inherited. urg.
......@@ -524,6 +534,8 @@ runInteractiveProcess (wchar_t *cmd, wchar_t *workingDirectory,
if (!mkAnonPipe(&hStdErrorRead, TRUE, &hStdErrorWrite, TRUE))
goto cleanup_err;
sInfo.hStdError = hStdErrorWrite;
} else if (fdStdErr == -2) {
sInfo.hStdError = NULL;
} else if (fdStdErr == 2) {
// Don't duplicate stderr, as console handles cannot be
// duplicated and inherited. urg.
......
# Changelog for [`process` package](http://hackage.haskell.org/package/process)
## 1.3.0.0 (unreleased)
* Add StdStream(NoStream) to have standard handles closed. [#13](https://github.com/haskell/process/pull/13)
## 1.2.3.0 *March 2015*
* [Meaningful error message when exe not found on close\_fds is
......
name: process
version: 1.2.3.0
version: 1.3.0.0
-- NOTE: Don't forget to update ./changelog.md
license: BSD3
license-file: LICENSE
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment