[commit: packages/process] master, new-flags, new-flags-no-f3df9d6: split the detached_console flag into two (58d7e5b)
git at git.haskell.org
git at git.haskell.org
Mon Nov 2 06:23:37 UTC 2015
Repository : ssh://git@git.haskell.org/process
On branches: master,new-flags,new-flags-no-f3df9d6
Link : http://ghc.haskell.org/trac/ghc/changeset/58d7e5b92063873142231b78c456dc890660d725/process
>---------------------------------------------------------------
commit 58d7e5b92063873142231b78c456dc890660d725
Author: Daniel Brooks <db48x at db48x.net>
Date: Tue Aug 18 05:59:49 2015 -0700
split the detached_console flag into two
the new flag new_session is unix-only and causes it to call setsid,
leaving detached_console to be windows only
Fixes #32
>---------------------------------------------------------------
58d7e5b92063873142231b78c456dc890660d725
System/Process.hsc | 6 ++++--
System/Process/Internals.hs | 15 ++++++++++-----
cbits/runProcess.c | 2 +-
include/processFlags.h | 1 +
4 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/System/Process.hsc b/System/Process.hsc
index 419f9f9..6c589df 100644
--- a/System/Process.hsc
+++ b/System/Process.hsc
@@ -125,7 +125,8 @@ proc cmd args = CreateProcess { cmdspec = RawCommand cmd args,
close_fds = False,
create_group = False,
delegate_ctlc = False,
- detach_console = False }
+ detach_console = False,
+ new_session = False }
-- | Construct a 'CreateProcess' record for passing to 'createProcess',
-- representing a command to be passed to the shell.
@@ -139,7 +140,8 @@ shell str = CreateProcess { cmdspec = ShellCommand str,
close_fds = False,
create_group = False,
delegate_ctlc = False,
- detach_console = False }
+ detach_console = False,
+ new_session = False }
{- |
This is the most general way to spawn an external process. The
diff --git a/System/Process/Internals.hs b/System/Process/Internals.hs
index 152edd7..d57fc8c 100644
--- a/System/Process/Internals.hs
+++ b/System/Process/Internals.hs
@@ -182,9 +182,10 @@ data CreateProcess = CreateProcess{
-- On Windows this has no effect.
--
-- /Since: 1.2.0.0/
- detach_console :: Bool -- ^ Detach the process from the console, so it has no controlling terminal.
+ detach_console :: Bool, -- ^ Use the windows DETACHED_PROCESS flag when creating the process; does nothing on other platforms.
--
- -- On Unix, this uses setsid, while on Windows, it uses DETACHED_PROCESS.
+ -- /Since: 1.3.0.0/
+ new_session :: Bool -- ^ Use posix setsid to start the new process in a new session; does nothing on other platforms.
--
-- /Since: 1.3.0.0/
}
@@ -264,7 +265,8 @@ createProcess_ fun CreateProcess{ cmdspec = cmdsp,
close_fds = mb_close_fds,
create_group = mb_create_group,
delegate_ctlc = mb_delegate_ctlc,
- detach_console = mb_detach_console }
+ detach_console = mb_detach_console,
+ new_session = mb_new_session }
= do
let (cmd,args) = commandToProcess cmdsp
withFilePathException cmd $
@@ -295,7 +297,8 @@ createProcess_ fun CreateProcess{ cmdspec = cmdsp,
(if mb_delegate_ctlc then 1 else 0)
((if mb_close_fds then RUN_PROCESS_IN_CLOSE_FDS else 0)
.|.(if mb_create_group then RUN_PROCESS_IN_NEW_GROUP else 0)
- .|.(if mb_detach_console then RUN_PROCESS_DETACHED else 0))
+ .|.(if mb_detach_console then RUN_PROCESS_DETACHED else 0)
+ .|.(if mb_new_session then RUN_PROCESS_NEW_SESSION else 0))
pFailedDoing
when (proc_handle == -1) $ do
@@ -427,7 +430,8 @@ createProcess_ fun CreateProcess{ cmdspec = cmdsp,
close_fds = mb_close_fds,
create_group = mb_create_group,
delegate_ctlc = _ignored,
- detach_console = mb_detach_console }
+ detach_console = mb_detach_console,
+ new_session = mb_new_session }
= do
(cmd, cmdline) <- commandToProcess cmdsp
withFilePathException cmd $
@@ -460,6 +464,7 @@ createProcess_ fun CreateProcess{ cmdspec = cmdsp,
((if mb_close_fds then RUN_PROCESS_IN_CLOSE_FDS else 0)
.|.(if mb_create_group then RUN_PROCESS_IN_NEW_GROUP else 0)
.|.(if mb_detach_console then RUN_PROCESS_DETACHED else 0))
+ .|.(if mb_new_session then RUN_PROCESS_NEW_SESSION else 0))
hndStdInput <- mbPipe mb_stdin pfdStdInput WriteMode
hndStdOutput <- mbPipe mb_stdout pfdStdOutput ReadMode
diff --git a/cbits/runProcess.c b/cbits/runProcess.c
index 7ca6be8..0c09419 100644
--- a/cbits/runProcess.c
+++ b/cbits/runProcess.c
@@ -138,7 +138,7 @@ runInteractiveProcess (char *const args[],
close(forkCommunicationFds[0]);
fcntl(forkCommunicationFds[1], F_SETFD, FD_CLOEXEC);
- if ((flags & RUN_PROCESS_DETACHED) != 0) {
+ if ((flags & RUN_PROCESS_NEW_SESSION) != 0) {
setsid();
}
if ((flags & RUN_PROCESS_IN_NEW_GROUP) != 0) {
diff --git a/include/processFlags.h b/include/processFlags.h
index 3b984d3..9de6a10 100644
--- a/include/processFlags.h
+++ b/include/processFlags.h
@@ -7,3 +7,4 @@
#define RUN_PROCESS_IN_CLOSE_FDS 0x1
#define RUN_PROCESS_IN_NEW_GROUP 0x2
#define RUN_PROCESS_DETACHED 0x4
+#define RUN_PROCESS_NEW_SESSION 0x8
More information about the ghc-commits
mailing list