package lwt
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=18742da8b8fe3618e3fa700b7a884fe7
sha512=1c51fdb4d0856c89e2df08a1c0095ef28ebd0f613b07b03d0f66501ca5486515562071291e6d0932e57587ed0c9362c8b92c5c9eddb4d2bb2f5e129986b484a7
doc/lwt.unix/Lwt_process/index.html
Module Lwt_processSource
Process management
This module allows you to spawn processes and communicate with them.
A command. The first field is the name of the executable and the second is the list of arguments. For example:
("ls", [|"ls"; "-l"|])Notes:
- if the name is the empty string, then the first argument will be used. You should specify a name only if you do not want the executable to be searched in the PATH. On Windows the only way to enable automatic search in PATH is to pass an empty name.
- it is possible to ``inline'' an argument, i.e. split it into multiple arguments. To do that prefix it with
"\000". For example:
("", [|"echo"; "\000foo bar"|])is the same as:
("", [|"echo"; "foo"; "bar"|])A command executed with the shell. (with "/bin/sh -c <cmd>" on Unix and "cmd.exe /c <cmd>" on Windows).
All the following functions take an optional argument timeout, in seconds. If specified, after expiration, the process will be sent a Unix.sigkill signal and channels will be closed. When the channels are closed, any pending I/O operations on them (such as Lwt_io.read_chars) fail with exception Lwt_io.Channel_closed.
High-level functions
Redirections
type redirection = [ | `Keep(*Point to the same file as in the parent.
*)| `Dev_null(*Redirect to
*)/dev/null(POSIX) ornul(Win32).| `Close(*Close the file descriptor.
*)| `FD_copy of Unix.file_descr(*Redirect to the file pointed to by
*)fd.fdremains open in the parent.| `FD_move of Unix.file_descr(*Redirect to the file pointed to by
*)fd.fdis then closed in the parent.
]File descriptor redirections. These are used with the ~stdin, ~stdout, and ~stderr arguments below to specify how the standard file descriptors should be redirected in the child process. All optional redirection arguments default to `Keep.
Executing
val exec :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdin:redirection ->
?stdout:redirection ->
?stderr:redirection ->
command ->
Unix.process_status Lwt.tExecutes the given command and returns its exit status.
Receiving
val pread :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdin:redirection ->
?stderr:redirection ->
command ->
string Lwt.tval pread_chars :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdin:redirection ->
?stderr:redirection ->
command ->
char Lwt_stream.tval pread_line :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdin:redirection ->
?stderr:redirection ->
command ->
string Lwt.tval pread_lines :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdin:redirection ->
?stderr:redirection ->
command ->
string Lwt_stream.tSending
val pwrite :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdout:redirection ->
?stderr:redirection ->
command ->
string ->
unit Lwt.tval pwrite_chars :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdout:redirection ->
?stderr:redirection ->
command ->
char Lwt_stream.t ->
unit Lwt.tval pwrite_line :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdout:redirection ->
?stderr:redirection ->
command ->
string ->
unit Lwt.tval pwrite_lines :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdout:redirection ->
?stderr:redirection ->
command ->
string Lwt_stream.t ->
unit Lwt.tMapping
val pmap :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stderr:redirection ->
command ->
string ->
string Lwt.tval pmap_chars :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stderr:redirection ->
command ->
char Lwt_stream.t ->
char Lwt_stream.tval pmap_line :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stderr:redirection ->
command ->
string ->
string Lwt.tval pmap_lines :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stderr:redirection ->
command ->
string Lwt_stream.t ->
string Lwt_stream.tSpawning processes
type state = | Running(*The process is still running
*)| Exited of Unix.process_status(*The process has exited
*)
State of a sub-process
class process_none : ?timeout:float -> ?env:string array -> ?cwd:string -> ?stdin:redirection -> ?stdout:
redirection -> ?stderr:redirection -> command -> object ... endval open_process_none :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdin:redirection ->
?stdout:redirection ->
?stderr:redirection ->
command ->
process_noneval with_process_none :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdin:redirection ->
?stdout:redirection ->
?stderr:redirection ->
command ->
(process_none -> 'a Lwt.t) ->
'a Lwt.tclass process_in : ?timeout:float -> ?env:string array -> ?cwd:string -> ?stdin:redirection -> ?stderr:
redirection -> command -> object ... endval open_process_in :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdin:redirection ->
?stderr:redirection ->
command ->
process_inval with_process_in :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdin:redirection ->
?stderr:redirection ->
command ->
(process_in -> 'a Lwt.t) ->
'a Lwt.tclass process_out : ?timeout:float -> ?env:string array -> ?cwd:string -> ?stdout:redirection -> ?stderr:
redirection -> command -> object ... endval open_process_out :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdout:redirection ->
?stderr:redirection ->
command ->
process_outval with_process_out :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stdout:redirection ->
?stderr:redirection ->
command ->
(process_out -> 'a Lwt.t) ->
'a Lwt.tclass process : ?timeout:float -> ?env:string array -> ?cwd:string -> ?stderr:redirection ->
command -> object ... endval open_process :
?timeout:float ->
?env:string array ->
?cwd:string ->
?stderr:redirection ->
command ->
processclass process_full : ?timeout:float -> ?env:string array -> ?cwd:string -> command -> object ... endval open_process_full :
?timeout:float ->
?env:string array ->
?cwd:string ->
command ->
process_fullval with_process_full :
?timeout:float ->
?env:string array ->
?cwd:string ->
command ->
(process_full -> 'a Lwt.t) ->
'a Lwt.t