HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleunix-2.8.7.0Haskell2010

System.Posix.Process

POSIX process support. See also the System.Cmd and System.Process modules in the process package.

  • 2 types
  • 25 values
  • Packageunix-2.8.7.0
  • Exports27
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceProcess.hsc

Processes

0 declarations

Forking and executing

valueforkProcess :: 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.

The exception masking state of the executed action is inherited (c.f. forkIO), see also forkProcessWithUnmask (since: 2.7.0.0).

forkProcess comes with a giant warning: since any other running threads are not copied into the child process, it's easy to go wrong: e.g. by accessing some shared resource that was held by another thread in the parent.

GHC note: forkProcess is not currently very well supported when using multiple capabilities (+RTS -N), although it is supported with -threaded as long as only one capability is being used.

valueexecuteFile
  1. :: FilePath

    Command

  2. -> Bool

    Search PATH?

  3. -> [String]

    Arguments

  4. -> Maybe [(String, String)]

    Environment

  5. -> IO a
#

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].

Exiting

valueexitImmediately :: ExitCode -> IO a
#

exitImmediately status calls _exit to terminate the process with the indicated exit status. The operation never returns. Since it does not use the Haskell exception system and it cannot be caught.

Note: Prior to unix-2.8.0.0 the type-signature of exitImmediately was ExitCode -> IO ().

Process environment

Process groups

Sessions

Process times

Scheduling priority

Process status

datadata ProcessStatus
#

The exit status of a process

Constructors

Instances3Eq, Ord, Show

getAnyProcessStatus blk stopped calls waitpid, returning Just (pid, tc), the ProcessID and ProcessStatus for any child process if a child process has exited, or Nothing if there are child processes but none have exited. If there are no child processes, then getAnyProcessStatus raises an isDoesNotExistError exception.

If blk is False, then WNOHANG is set in the options for waitpid, otherwise not. If stopped is True, then WUNTRACED is set in the options for waitpid, otherwise not.

getGroupProcessStatus blk stopped pgid calls waitpid, returning Just (pid, tc), the ProcessID and ProcessStatus for any process in group pgid if one is available, or Nothing if there are child processes but none have exited. If there are no child processes, then getGroupProcessStatus raises an isDoesNotExistError exception.

If blk is False, then WNOHANG is set in the options for waitpid, otherwise not. If stopped is True, then WUNTRACED is set in the options for waitpid, otherwise not.

Deprecated

Deprecated. This function is scheduled to be replaced by something different in the future, we therefore recommend that you do not use this version and use createProcessGroupFor instead.

createProcessGroup pid calls setpgid to make process pid a new process group leader. This function is currently deprecated, and might be changed to making the current process a new process group leader in future versions.