{-# LINE1"System/Posix/Process.hsc"#-}{-# LINE2"System/Posix/Process.hsc"#-}{-# LANGUAGE Safe #-}{-# LINE6"System/Posix/Process.hsc"#-}------------------------------------------------------------------------------- |-- Module : System.Posix.Process-- Copyright : (c) The University of Glasgow 2002-- License : BSD-style (see the file libraries/base/LICENSE)---- Maintainer : libraries@haskell.org-- Stability : provisional-- Portability : non-portable (requires POSIX)---- POSIX process support. See also the System.Cmd and System.Process-- modules in the process package.-------------------------------------------------------------------------------moduleSystem.Posix.Process(-- * Processes-- ** Forking and executingforkProcess,forkProcessWithUnmask,executeFile,-- ** ExitingexitImmediately,-- ** Process environmentgetProcessID,getParentProcessID,-- ** Process groupsgetProcessGroupID,getProcessGroupIDOf,createProcessGroupFor,joinProcessGroup,setProcessGroupIDOf,-- ** SessionscreateSession,-- ** Process timesProcessTimes(..),getProcessTimes,-- ** Scheduling prioritynice,getProcessPriority,getProcessGroupPriority,getUserPriority,setProcessPriority,setProcessGroupPriority,setUserPriority,-- ** Process statusProcessStatus(..),getProcessStatus,getAnyProcessStatus,getGroupProcessStatus,-- ** DeprecatedcreateProcessGroup,setProcessGroupID,)whereimportForeignimportForeign.CimportSystem.Posix.Process.InternalsimportSystem.Posix.Process.CommonimportSystem.Posix.Internals(withFilePath)-- | @'executeFile' cmd args env@ calls one of the-- @execv*@ family, depending on whether or not the current-- PATH is to be searched for the command, and whether or not an-- environment is provided to supersede the process's current-- environment. The basename (leading directory names suppressed) of-- the command is passed to @execv*@ as @arg[0]@;-- the argument list passed to 'executeFile' therefore-- begins with @arg[1]@.executeFile::FilePath-- ^ Command->Bool-- ^ Search PATH?->[String]-- ^ Arguments->Maybe[(String,String)]-- ^ Environment->IOaexecuteFilepathsearchargsNothing=dowithFilePathpath$\s->withManywithFilePath(path:args)$\cstrs->withArray0nullPtrcstrs$\arr->dopPrPr_disableITimersifsearchthenthrowErrnoPathIfMinus1_"executeFile"path(c_execvpsarr)elsethrowErrnoPathIfMinus1_"executeFile"path(c_execvsarr)returnundefined-- never reachedexecuteFilepathsearchargs(Justenv)=dowithFilePathpath$\s->withManywithFilePath(path:args)$\cstrs->withArray0nullPtrcstrs$\arg_arr->letenv'=map(\(name,val)->name++('=':val))envinwithManywithFilePathenv'$\cenv->withArray0nullPtrcenv$\env_arr->dopPrPr_disableITimersifsearchthenthrowErrnoPathIfMinus1_"executeFile"path(c_execvpesarg_arrenv_arr)elsethrowErrnoPathIfMinus1_"executeFile"path(c_execvesarg_arrenv_arr)returnundefined-- never reachedforeignimportccallunsafe"execvp"c_execvp::CString->PtrCString->IOCIntforeignimportccallunsafe"execv"c_execv::CString->PtrCString->IOCIntforeignimportccallunsafe"execve"c_execve::CString->PtrCString->PtrCString->IOCInt