[project @ 2004-10-13 10:24:16 by simonpj]
[ghc-base.git] / System / Process / Internals.hs
1 {-# OPTIONS -cpp -fffi #-}
2 -----------------------------------------------------------------------------
3 -- |
4 -- Module      :  System.Process.Internals
5 -- Copyright   :  (c) The University of Glasgow 2004
6 -- License     :  BSD-style (see the file libraries/base/LICENSE)
7 -- 
8 -- Maintainer  :  libraries@haskell.org
9 -- Stability   :  experimental
10 -- Portability :  portable
11 --
12 -- Operations for creating and interacting with sub-processes.
13 --
14 -----------------------------------------------------------------------------
15
16 -- #hide
17 module System.Process.Internals (
18         ProcessHandle(..), PHANDLE,
19 #if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
20          pPrPr_disableITimers, c_execvpe
21 #endif
22   ) where
23
24 #if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
25 import System.Posix.Types ( CPid )
26 #else
27 import Data.Word ( Word32 )
28 #endif
29 import Foreign.C.String ( CString )
30 import Foreign.C.Types ( CInt )
31 import Foreign.Ptr ( Ptr )
32
33 #ifdef __HUGS__
34 {-# CBITS execvpe.c  #-}
35 #endif
36
37 -- ----------------------------------------------------------------------------
38 -- ProcessHandle type
39
40 {- | A handle to a process, which can be used to wait for termination
41      of the process using 'waitForProcess'.
42
43      None of the process-creation functions in this library wait for
44      termination: they all return a 'ProcessHandle' which may be used
45      to wait for the process later.
46 -}
47 #if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
48 type PHANDLE = CPid
49 #else
50 type PHANDLE = Word32
51 #endif
52
53 newtype ProcessHandle = ProcessHandle PHANDLE
54
55 -- ----------------------------------------------------------------------------
56
57 #if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
58
59 -- this function disables the itimer, which would otherwise cause confusing
60 -- signals to be sent to the new process.
61 foreign import ccall unsafe "pPrPr_disableITimers"
62   pPrPr_disableITimers :: IO ()
63
64 foreign import ccall unsafe "execvpe"
65   c_execvpe :: CString -> Ptr CString -> Ptr CString -> IO CInt
66
67 #endif