aboutsummaryrefslogtreecommitdiffhomepage
path: root/System/Posix/Process.hsc
diff options
context:
space:
mode:
authorGravatar simonmar <unknown>2002-12-19 13:52:55 +0000
committerGravatar simonmar <unknown>2002-12-19 13:52:55 +0000
commitf46082b665d7748bdec2981e21d332ee90a7c1cd (patch)
treef6f6b13fc4d7b60694430ccf8be29f97bed2e57d /System/Posix/Process.hsc
parent7ad2b37cfbe3977a0a5e69c85941aa84c9e57286 (diff)
[project @ 2002-12-19 13:52:55 by simonmar]
Fill in some more bits in the new Unix library: specifically the contents of PosixTTY and PosixDB (now System.Posix.Terminal and System.Posix.User respectively). We're now about 95% complete w.r.t. the old posix library. I've identified the reminaing bits to do in System/Posix.hs.
Diffstat (limited to 'System/Posix/Process.hsc')
-rw-r--r--System/Posix/Process.hsc42
1 files changed, 17 insertions, 25 deletions
diff --git a/System/Posix/Process.hsc b/System/Posix/Process.hsc
index e20830c..ec0bc33 100644
--- a/System/Posix/Process.hsc
+++ b/System/Posix/Process.hsc
@@ -60,21 +60,8 @@ module System.Posix.Process (
-- getEnvironment,
) where
-#include "config.h"
#include "HsUnix.h"
-#ifdef HAVE_SYS_TIMES_H
-#include <sys/times.h>
-#endif
-
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
-
import Foreign
import Foreign.C
import System.IO
@@ -230,24 +217,29 @@ executeFile :: FilePath -- Command
-> IO ()
executeFile path search args Nothing = do
withCString path $ \s ->
- withMany withCString args $ \cstrs ->
- withArray0 nullPtr cstrs $ \arr ->
- if search then
- throwErrnoIfMinus1_ "executeFile" (c_execvp s arr)
- else
- throwErrnoIfMinus1_ "executeFile" (c_execv s arr)
+ withMany withCString (path:args) $ \cstrs ->
+ withArray0 nullPtr cstrs $ \arr -> do
+ pPrPr_disableITimers
+ if search
+ then throwErrnoIfMinus1_ "executeFile" (c_execvp s arr)
+ else throwErrnoIfMinus1_ "executeFile" (c_execv s arr)
executeFile path search args (Just env) = do
withCString path $ \s ->
- withMany withCString args $ \cstrs ->
+ withMany withCString (path:args) $ \cstrs ->
withArray0 nullPtr cstrs $ \arg_arr ->
let env' = map (\ (name, val) -> name ++ ('=' : val)) env in
withMany withCString env' $ \cenv ->
- withArray0 nullPtr cenv $ \env_arr ->
- if search then
- throwErrnoIfMinus1_ "executeFile" (c_execvpe s arg_arr env_arr)
- else
- throwErrnoIfMinus1_ "executeFile" (c_execve s arg_arr env_arr)
+ withArray0 nullPtr cenv $ \env_arr -> do
+ pPrPr_disableITimers
+ if search
+ then throwErrnoIfMinus1_ "executeFile" (c_execvpe s arg_arr env_arr)
+ else throwErrnoIfMinus1_ "executeFile" (c_execve s arg_arr env_arr)
+
+-- this function disables the itimer, which would otherwise cause confusing
+-- signals to be sent to the new process.
+foreign import ccall unsafe "pPrPr_disableITimers"
+ pPrPr_disableITimers :: IO ()
foreign import ccall unsafe "execvp"
c_execvp :: CString -> Ptr CString -> IO CInt