eb16d368bb82ecaaa97c54bf31ca270e27853c65
[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, pPrPr_disableITimers, c_execvpe
19   ) where
20
21 #if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
22 import System.Posix.Types ( CPid )
23 #else
24 import Data.Word ( Word32 )
25 #endif
26 import Foreign.C.String ( CString )
27 import Foreign.C.Types ( CInt )
28 import Foreign.Ptr ( Ptr )
29
30 #ifdef __HUGS__
31 {-# CBITS execvpe.c  #-}
32 #endif
33
34 -- ----------------------------------------------------------------------------
35 -- ProcessHandle type
36
37 {- | A handle to a process, which can be used to wait for termination
38      of the process using 'waitForProcess'.
39
40      None of the process-creation functions in this library wait for
41      termination: they all return a 'ProcessHandle' which may be used
42      to wait for the process later.
43 -}
44 #if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
45 type PHANDLE = CPid
46 #else
47 type PHANDLE = Word32
48 #endif
49
50 newtype ProcessHandle = ProcessHandle PHANDLE
51
52 -- ----------------------------------------------------------------------------
53
54 -- this function disables the itimer, which would otherwise cause confusing
55 -- signals to be sent to the new process.
56 foreign import ccall unsafe "pPrPr_disableITimers"
57   pPrPr_disableITimers :: IO ()
58
59 foreign import ccall unsafe "execvpe"
60   c_execvpe :: CString -> Ptr CString -> Ptr CString -> IO CInt