|
System.Posix.Process | Portability | non-portable (requires POSIX) | Stability | provisional | Maintainer | libraries@haskell.org |
|
|
|
|
|
Description |
POSIX process support
|
|
Synopsis |
|
|
|
|
Processes
|
|
Forking and executing
|
|
forkProcess :: IO () -> IO ProcessID |
forkProcess corresponds to the POSIX fork system call.
The IO action passed as an argument is executed in the child process; no other
threads will be copied to the child process.
On success, forkProcess returns the child's ProcessID to the parent process;
in case of an error, an exception is thrown.
|
|
executeFile :: FilePath -> Bool -> [String] -> Maybe [(String, String)] -> IO () |
literal>executeFile cmd args env</literal calls one of the
function>execv*</function 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 function>execv*</function> as <varname>arg[0]</varname;
the argument list passed to function>executeFile</function therefore
begins with varname>arg[1]</varname.
|
|
Exiting
|
|
exitImmediately :: ExitCode -> IO () |
literal>exitImmediately status</literal> calls <function>_exit</function to terminate the process
with the indicated exit literal>status</literal.
The operation never returns.
|
|
Process environment
|
|
getProcessID :: IO ProcessID |
function>getProcessID</function> calls <function>getpid</function to obtain
the literal>ProcessID</literal for
the current process.
|
|
getParentProcessID :: IO ProcessID |
function>getProcessID</function> calls <function>getppid</function> to obtain the <literal>ProcessID</literal for
the parent of the current process.
|
|
getProcessGroupID :: IO ProcessGroupID |
function>getProcessGroupID</function> calls <function>getpgrp</function to obtain the
literal>ProcessGroupID</literal for the current process.
|
|
Process groups
|
|
createProcessGroup :: ProcessID -> IO ProcessGroupID |
literal>createProcessGroup pid</literal> calls <function>setpgid</function to make
process literal>pid</literal a new process group leader.
|
|
joinProcessGroup :: ProcessGroupID -> IO () |
literal>joinProcessGroup pgid</literal> calls <function>setpgid</function to set the
literal>ProcessGroupID</literal> of the current process to <literal>pgid</literal.
|
|
setProcessGroupID :: ProcessID -> ProcessGroupID -> IO () |
literal>setProcessGroupID pid pgid</literal> calls <function>setpgid</function to set the
literal>ProcessGroupID</literal> for process <literal>pid</literal> to <literal>pgid</literal.
|
|
Sessions
|
|
createSession :: IO ProcessGroupID |
function>createSession</function> calls <function>setsid</function to create a new session
with the current process as session leader.
|
|
Process times
|
|
data ProcessTimes |
|
|
getProcessTimes :: IO ProcessTimes |
function>getProcessTimes</function> calls <function>times</function to obtain time-accounting
information for the current process and its children.
|
|
Scheduling priority
|
|
nice :: Int -> IO () |
|
getProcessPriority :: ProcessID -> IO Int |
|
getProcessGroupPriority :: ProcessGroupID -> IO Int |
|
getUserPriority :: UserID -> IO Int |
|
setProcessPriority :: ProcessID -> Int -> IO () |
|
setProcessGroupPriority :: ProcessGroupID -> Int -> IO () |
|
setUserPriority :: UserID -> Int -> IO () |
|
Process status
|
|
data ProcessStatus |
Constructors | | Instances | |
|
|
getProcessStatus :: Bool -> Bool -> ProcessID -> IO (Maybe ProcessStatus) |
literal>getProcessStatus blk stopped pid</literal> calls <function>waitpid</function, returning
literal>Just tc</literal>, the <literal>ProcessStatus</literal> for process <literal>pid</literal if it is
available, literal>Nothing</literal> otherwise. If <literal>blk</literal> is <literal>False</literal, then
literal>WNOHANG</literal> is set in the options for <function>waitpid</function, otherwise not.
If literal>stopped</literal> is <literal>True</literal>, then <literal>WUNTRACED</literal is set in the
options for function>waitpid</function, otherwise not.
|
|
getAnyProcessStatus :: Bool -> Bool -> IO (Maybe (ProcessID, ProcessStatus)) |
literal>getAnyProcessStatus blk stopped</literal> calls <function>waitpid</function, returning
literal>Just (pid, tc)</literal>, the <literal>ProcessID</literal> and <literal>ProcessStatus</literal for any
child process if one is available, literal>Nothing</literal otherwise. If
literal>blk</literal> is <literal>False</literal>, then <literal>WNOHANG</literal is set in the options for
function>waitpid</function>, otherwise not. If <literal>stopped</literal> is <literal>True</literal, then
literal>WUNTRACED</literal> is set in the options for <function>waitpid</function, otherwise not.
|
|
getGroupProcessStatus :: Bool -> Bool -> ProcessGroupID -> IO (Maybe (ProcessID, ProcessStatus)) |
literal>getGroupProcessStatus blk stopped pgid</literal> calls <function>waitpid</function,
returning literal>Just (pid, tc)</literal>, the <literal>ProcessID</literal and
literal>ProcessStatus</literal> for any process in group <literal>pgid</literal if one is
available, literal>Nothing</literal> otherwise. If <literal>blk</literal> is <literal>False</literal, then
literal>WNOHANG</literal> is set in the options for <function>waitpid</function, otherwise not.
If literal>stopped</literal> is <literal>True</literal>, then <literal>WUNTRACED</literal is set in the
options for function>waitpid</function, otherwise not.
|
|
Produced by Haddock version 0.7 |