Safe Haskell | None |
---|---|
Language | GHC2021 |
Effectful.Process.Dynamic
Description
Provides a dynamic effect for typed process.
Since: 0.1
Synopsis
- data Process (a :: Type -> Type) b
- runProcess :: forall (es :: [Effect]) a. (HasCallStack, IOE :> es) => Eff (Process ': es) a -> Eff es a
- createProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => CreateProcess -> Eff es (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
- createProcess_ :: forall (es :: [Effect]). (HasCallStack, Process :> es) => String -> CreateProcess -> Eff es (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
- shell :: String -> CreateProcess
- proc :: FilePath -> [String] -> CreateProcess
- data CreateProcess = CreateProcess {
- cmdspec :: CmdSpec
- cwd :: Maybe FilePath
- env :: Maybe [(String, String)]
- std_in :: StdStream
- std_out :: StdStream
- std_err :: StdStream
- close_fds :: Bool
- create_group :: Bool
- delegate_ctlc :: Bool
- detach_console :: Bool
- create_new_console :: Bool
- new_session :: Bool
- child_group :: Maybe GroupID
- child_user :: Maybe UserID
- use_process_jobs :: Bool
- data CmdSpec
- data StdStream
- data ProcessHandle
- callProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => FilePath -> [String] -> Eff es ()
- callCommand :: forall (es :: [Effect]). (HasCallStack, Process :> es) => String -> Eff es ()
- spawnProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => FilePath -> [String] -> Eff es ProcessHandle
- spawnCommand :: forall (es :: [Effect]). (HasCallStack, Process :> es) => String -> Eff es ProcessHandle
- readCreateProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => CreateProcess -> String -> Eff es String
- readProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => FilePath -> [String] -> String -> Eff es String
- readCreateProcessWithExitCode :: forall (es :: [Effect]). (HasCallStack, Process :> es) => CreateProcess -> String -> Eff es (ExitCode, String, String)
- readProcessWithExitCode :: forall (es :: [Effect]). (HasCallStack, Process :> es) => FilePath -> [String] -> String -> Eff es (ExitCode, String, String)
- withCreateProcess :: forall (es :: [Effect]) a. (HasCallStack, Process :> es) => CreateProcess -> (Maybe Handle -> Maybe Handle -> Maybe Handle -> ProcessHandle -> Eff es a) -> Eff es a
- cleanupProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -> Eff es ()
- showCommandForUser :: FilePath -> [String] -> String
- type Pid = CPid
- getPid :: forall (es :: [Effect]). (HasCallStack, Process :> es) => ProcessHandle -> Eff es (Maybe Pid)
- getCurrentPid :: forall (es :: [Effect]). (HasCallStack, Process :> es) => Eff es Pid
- waitForProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => ProcessHandle -> Eff es ExitCode
- getProcessExitCode :: forall (es :: [Effect]). (HasCallStack, Process :> es) => ProcessHandle -> Eff es (Maybe ExitCode)
- terminateProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => ProcessHandle -> Eff es ()
- interruptProcessGroupOf :: forall (es :: [Effect]). (HasCallStack, Process :> es) => ProcessHandle -> Eff es ()
- createPipe :: forall (es :: [Effect]). (HasCallStack, Process :> es) => Eff es (Handle, Handle)
- createPipeFd :: forall (es :: [Effect]). (HasCallStack, Process :> es) => Eff es (FD, FD)
- type FD = CInt
- data Handle
Effect
The full definition for Process
is exported from
Effectful.Process.Dynamic.Effect, due to a name clash between some of
its constructors and process re-exports. Hence if you need the data
constructors, import that module qualified.
data Process (a :: Type -> Type) b Source #
Dynamic effect for process.
Since: 0.1
Instances
ShowEffect Process Source # | Since: 0.1 |
Defined in Effectful.Process.Dynamic.Effect | |
type DispatchOf Process Source # | |
Defined in Effectful.Process.Dynamic.Effect |
Handler
runProcess :: forall (es :: [Effect]) a. (HasCallStack, IOE :> es) => Eff (Process ': es) a -> Eff es a Source #
API
Running sub-processes
createProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => CreateProcess -> Eff es (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) Source #
Lifted createProcess
.
Since: 0.1
createProcess_ :: forall (es :: [Effect]). (HasCallStack, Process :> es) => String -> CreateProcess -> Eff es (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) Source #
Lifted createProcess_
.
Since: 0.1
shell :: String -> CreateProcess #
Construct a CreateProcess
record for passing to createProcess
,
representing a command to be passed to the shell.
proc :: FilePath -> [String] -> CreateProcess #
Construct a CreateProcess
record for passing to createProcess
,
representing a raw command with arguments.
See RawCommand
for precise semantics of the specified FilePath
.
data CreateProcess #
Constructors
CreateProcess | |
Fields
|
Instances
Show CreateProcess | |
Defined in System.Process.Common Methods showsPrec :: Int -> CreateProcess -> ShowS # show :: CreateProcess -> String # showList :: [CreateProcess] -> ShowS # | |
Eq CreateProcess | |
Defined in System.Process.Common Methods (==) :: CreateProcess -> CreateProcess -> Bool # (/=) :: CreateProcess -> CreateProcess -> Bool # |
Constructors
ShellCommand String | A command line to execute using the shell |
RawCommand FilePath [String] | The name of an executable with a list of arguments The
Windows does not have a mechanism for passing multiple arguments.
When using |
Instances
IsString CmdSpec | construct a Since: process-1.2.1.0 |
Defined in System.Process.Common Methods fromString :: String -> CmdSpec # | |
Show CmdSpec | |
Eq CmdSpec | |
Constructors
Inherit | Inherit Handle from parent |
UseHandle Handle | Use the supplied Handle |
CreatePipe | Create a new pipe. The returned
|
NoStream | Close the stream's file descriptor without
passing a Handle. On POSIX systems this may
lead to strange behavior in the child process
because attempting to read or write after the
file has been closed throws an error. This
should only be used with child processes that
don't use the file descriptor at all. If you
wish to ignore the child process's output you
should either create a pipe and drain it
manually or pass a |
Instances
data ProcessHandle #
A handle to a process, which can be used to wait for termination
of the process using waitForProcess
.
None of the process-creation functions in this library wait for
termination: they all return a ProcessHandle
which may be used
to wait for the process later.
On Windows a second wait method can be used to block for event completion. This requires two handles. A process job handle and a events handle to monitor.
Simpler functions for common tasks
callProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => FilePath -> [String] -> Eff es () Source #
Lifted callProcess
.
Since: 0.1
callCommand :: forall (es :: [Effect]). (HasCallStack, Process :> es) => String -> Eff es () Source #
Lifted callCommand
.
Since: 0.1
spawnProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => FilePath -> [String] -> Eff es ProcessHandle Source #
Lifted spawnProcess
.
Since: 0.1
spawnCommand :: forall (es :: [Effect]). (HasCallStack, Process :> es) => String -> Eff es ProcessHandle Source #
Lifted spawnCommand
.
Since: 0.1
readCreateProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => CreateProcess -> String -> Eff es String Source #
Lifted readCreateProcess
.
Since: 0.1
readProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => FilePath -> [String] -> String -> Eff es String Source #
Lifted readProcess
.
Since: 0.1
readCreateProcessWithExitCode :: forall (es :: [Effect]). (HasCallStack, Process :> es) => CreateProcess -> String -> Eff es (ExitCode, String, String) Source #
Lifted readCreateProcessWithExitCode
.
Since: 0.1
readProcessWithExitCode :: forall (es :: [Effect]). (HasCallStack, Process :> es) => FilePath -> [String] -> String -> Eff es (ExitCode, String, String) Source #
Lifted readProcessWithExitCode
.
Since: 0.1
withCreateProcess :: forall (es :: [Effect]) a. (HasCallStack, Process :> es) => CreateProcess -> (Maybe Handle -> Maybe Handle -> Maybe Handle -> ProcessHandle -> Eff es a) -> Eff es a Source #
Lifted withCreateProcess
.
Since: 0.1
cleanupProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -> Eff es () Source #
Lifted cleanupProcess
.
Since: 0.1
Related utilities
showCommandForUser :: FilePath -> [String] -> String #
Given a program p
and arguments args
,
showCommandForUser p args
returns a string suitable for pasting
into /bin/sh
(on Unix systems) or CMD.EXE
(on Windows).
The platform specific type for a process identifier.
This is always an integral type. Width and signedness are platform specific.
Since: process-1.6.3.0
getPid :: forall (es :: [Effect]). (HasCallStack, Process :> es) => ProcessHandle -> Eff es (Maybe Pid) Source #
Lifted getPid
.
Since: 0.1
getCurrentPid :: forall (es :: [Effect]). (HasCallStack, Process :> es) => Eff es Pid Source #
Lifted getCurrentPid
.
Since: 0.1
waitForProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => ProcessHandle -> Eff es ExitCode Source #
Lifted waitForProcess
.
Since: 0.1
getProcessExitCode :: forall (es :: [Effect]). (HasCallStack, Process :> es) => ProcessHandle -> Eff es (Maybe ExitCode) Source #
Lifted getProcessExitCode
.
Since: 0.1
terminateProcess :: forall (es :: [Effect]). (HasCallStack, Process :> es) => ProcessHandle -> Eff es () Source #
Lifted terminateProcess
.
Since: 0.1
interruptProcessGroupOf :: forall (es :: [Effect]). (HasCallStack, Process :> es) => ProcessHandle -> Eff es () Source #
Lifted interruptProcessGroupOf
.
Since: 0.1
createPipe :: forall (es :: [Effect]). (HasCallStack, Process :> es) => Eff es (Handle, Handle) Source #
Lifted createPipe
.
Since: 0.1
createPipeFd :: forall (es :: [Effect]). (HasCallStack, Process :> es) => Eff es (FD, FD) Source #
Lifted createPipeFd
.
Since: 0.1
Re-exports
Haskell defines operations to read and write characters from and to files,
represented by values of type Handle
. Each value of this type is a
handle: a record used by the Haskell run-time system to manage I/O
with file system objects. A handle has at least the following properties:
- whether it manages input or output or both;
- whether it is open, closed or semi-closed;
- whether the object is seekable;
- whether buffering is disabled, or enabled on a line or block basis;
- a buffer (whose length may be zero).
Most handles will also have a current I/O position indicating where the next
input or output operation will occur. A handle is readable if it
manages only input or both input and output; likewise, it is writable if
it manages only output or both input and output. A handle is open when
first allocated.
Once it is closed it can no longer be used for either input or output,
though an implementation cannot re-use its storage while references
remain to it. Handles are in the Show
and Eq
classes. The string
produced by showing a handle is system dependent; it should include
enough information to identify the handle for debugging. A handle is
equal according to ==
only to itself; no attempt
is made to compare the internal state of different handles for equality.