[project @ 2005-01-11 16:04:08 by simonmar]
[packages/old-time.git] / System / Process / Internals.hs
1 {-# OPTIONS_GHC -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 import Prelude -- necessary to get dependencies right
25
26 #if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
27 import System.Posix.Types ( CPid )
28 #else
29 import Data.Word ( Word32 )
30 #endif
31 import Foreign.C.String ( CString )
32 import Foreign.C.Types ( CInt )
33 import Foreign.Ptr ( Ptr )
34
35 #ifdef __HUGS__
36 {-# CFILES cbits/execvpe.c #-}
37 #endif
38
39 -- ----------------------------------------------------------------------------
40 -- ProcessHandle type
41
42 {- | A handle to a process, which can be used to wait for termination
43 of the process using 'waitForProcess'.
44
45 None of the process-creation functions in this library wait for
46 termination: they all return a 'ProcessHandle' which may be used
47 to wait for the process later.
48 -}
49 #if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
50 type PHANDLE = CPid
51 #else
52 type PHANDLE = Word32
53 #endif
54
55 newtype ProcessHandle = ProcessHandle PHANDLE
56
57 -- ----------------------------------------------------------------------------
58
59 #if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
60
61 -- this function disables the itimer, which would otherwise cause confusing
62 -- signals to be sent to the new process.
63 foreign import ccall unsafe "pPrPr_disableITimers"
64 pPrPr_disableITimers :: IO ()
65
66 foreign import ccall unsafe "execvpe"
67 c_execvpe :: CString -> Ptr CString -> Ptr CString -> IO CInt
68
69 #endif