[commit: process] master: Merge old fix in, but leave out the process ID from ProcessInfo (d3270cd)

Simon Marlow marlowsd at gmail.com
Wed May 11 11:12:34 CEST 2011


Repository : ssh://darcs.haskell.org//srv/darcs/packages/process

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/d3270cd5980f2e997f19f34794e420bddbcaae0f

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

commit d3270cd5980f2e997f19f34794e420bddbcaae0f
Merge: 643f9e0... 192b791...
Author: Hamish Mackenzie <Hamish.K.Mackenzie at googlemail.com>
Date:   Sun Apr 24 04:58:14 2011 +1200

    Merge old fix in, but leave out the process ID from ProcessInfo

 System/Process.hs           |   43 ++++++++++++++++++++++++++++++++++++++++---
 System/Process/Internals.hs |   33 ++++++++++++++++++++-------------
 cbits/runProcess.c          |   27 +++++++++++++++++++--------
 include/processFlags.h      |    8 ++++++++
 include/runProcess.h        |    6 ++++--
 process.cabal               |    5 ++++-
 tests/3994.hs               |   22 ++++++++++++++++++++++
 tests/3994.stdout           |    2 ++
 tests/all.T                 |    2 ++
 9 files changed, 121 insertions(+), 27 deletions(-)

diff --cc System/Process.hs
index 6ecc8ca,452a15a..677b446
--- a/System/Process.hs
+++ b/System/Process.hs
@@@ -541,6 -546,37 +546,38 @@@ terminateProcess ph = d
  	-- again, or get its exit code.
  
  -- ----------------------------------------------------------------------------
+ -- interruptProcessGroupOf
+ 
+ -- | Sends an interrupt signal to the process group of the given process.
+ --
+ -- On Unix systems, it sends the group the SIGINT signal.
+ --
+ -- On Windows systems, it generates a CTRL_BREAK_EVENT and will only work for
+ -- processes created using 'createProcess' and setting the 'create_group' flag
+ 
+ interruptProcessGroupOf
+     :: ProcessHandle    -- ^ Lead process in the process group
+     -> IO ()
+ interruptProcessGroupOf ph = do
+ #if mingw32_HOST_OS
 -    withProcessInfo_ ph $ \p_ -> do
++    withProcessHandle_ ph $ \p_ -> do
+         case p_ of
 -            ClosedInfo _ -> return p_
 -            OpenInfo (h, Just pid) -> do
 -                generateConsoleCtrlEvent cTRL_BREAK_EVENT pid
++            ClosedHandle _ -> return p_
++            OpenHandle h -> do
++				-- getProcessId h
++                -- generateConsoleCtrlEvent cTRL_BREAK_EVENT pid
+                 return p_
+             _ -> return p_
+ #else
+     withProcessHandle_ ph $ \p_ -> do
+         case p_ of
+             ClosedHandle _ -> return p_
+             OpenHandle h -> do
+                 signalProcessGroup sigINT h
+                 return p_
+ #endif
+ 
+ -- ----------------------------------------------------------------------------
  -- getProcessExitCode
  
  {- | 
diff --cc System/Process/Internals.hs
index c868d98,cdca58c..5056055
--- a/System/Process/Internals.hs
+++ b/System/Process/Internals.hs
@@@ -333,7 -403,9 +338,8 @@@ runGenProcess_ fun CreateProcess{ cmdsp
  	                 c_runInteractiveProcess pcmdline pWorkDir pEnv 
                                  fdin fdout fderr
  				pfdStdInput pfdStdOutput pfdStdError
-                                 (if mb_close_fds 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))
 -                                pPid
  
       hndStdInput  <- mbPipe mb_stdin  pfdStdInput  WriteMode
       hndStdOutput <- mbPipe mb_stdout pfdStdOutput ReadMode
diff --cc cbits/runProcess.c
index 3a3d6c2,4cd27ad..6a2520f
--- a/cbits/runProcess.c
+++ b/cbits/runProcess.c
@@@ -352,7 -359,7 +359,7 @@@ runInteractiveProcess (wchar_t *cmd, wc
                         void *environment,
                         int fdStdIn, int fdStdOut, int fdStdErr,
  		       int *pfdStdInput, int *pfdStdOutput, int *pfdStdError,
-                        int close_fds)
 -                       int flags, long * pPid)
++                       int flags)
  {
  	STARTUPINFO sInfo;
  	PROCESS_INFORMATION pInfo;
diff --cc include/runProcess.h
index 4dda6e5,77bcd05..6838f5b
--- a/include/runProcess.h
+++ b/include/runProcess.h
@@@ -44,11 -44,13 +44,13 @@@ typedef pid_t ProcHandle
  typedef long ProcHandle;
  #endif
  
+ #include "processFlags.h"
+ 
  #if !(defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32))
  
 -extern ProcHandle runInteractiveProcess( char *const args[],
 -					 char *workingDirectory,
 -					 char **environment,
 +extern ProcHandle runInteractiveProcess( char *const args[], 
 +					 char *workingDirectory, 
 +					 char **environment, 
                                           int fdStdIn, int fdStdOut, int fdStdErr,
  					 int *pfdStdInput, 
  					 int *pfdStdOutput, 
@@@ -66,7 -68,7 +68,7 @@@ extern ProcHandle runInteractiveProcess
  					 int *pfdStdInput,
  					 int *pfdStdOutput,
  					 int *pfdStdError,
-                                          int close_fds);
 -                                         int flags, long *pPid);
++                                         int flags);
  
  #endif
  





More information about the Cvs-libraries mailing list