module CCUnix:sig..end
Some useful functions built on top of Unix.
status: unstable
Since 0.10
type'aor_error =('a, string) Result.result
type'agen =unit -> 'a option
val escape_str : string -> stringtype call_result = <
|
errcode : |
(* |
Extracted from status
| *) |
|
status : |
|||
|
stderr : |
|||
|
stdout : |
val call_full : ?bufsize:int ->
?stdin:[ `Gen of string gen | `Str of string ] ->
?env:string array ->
('a, Buffer.t, unit, call_result) Pervasives.format4 -> 'acall_full cmd wraps the result of Unix.open_process_full cmd into an
object. It reads the full stdout and stderr of the subprocess before
returning.bufsize : buffer size used to read stdout and stderrstdin : if provided, the generator or string is consumed and fed to
the subprocess input channel, which is then closed.env : environment to run the command inval call : ?bufsize:int ->
?stdin:[ `Gen of string gen | `Str of string ] ->
?env:string array ->
('a, Buffer.t, unit, string * string * int) Pervasives.format4 -> 'acall cmd is similar to call_full cmd but returns
a tuple stdout, stderr, errcode instead of an object.val call_stdout : ?bufsize:int ->
?stdin:[ `Gen of string gen | `Str of string ] ->
?env:string array -> ('a, Buffer.t, unit, string) Pervasives.format4 -> 'a
typeline =string
type async_call_result = <
|
close_all : |
|
close_err : |
|
close_in : |
|
close_out : |
|
stderr : |
|
stdin : |
|
stdout : |
|
wait : |
|
wait_errcode : |
val async_call : ?env:string array ->
('a, Buffer.t, unit, async_call_result) Pervasives.format4 -> 'aCCUnix.call, but the subprocess's channels are
line generators and line sinks (for stdin).
if p is async_call "cmd", then p#wait waits for the subprocess
to die. Channels can be closed independently.val stdout : < stdout : 'a; .. > -> 'a
val stderr : < stderr : 'a; .. > -> 'a
val status : < status : 'a; .. > -> 'a
val errcode : < errcode : 'a; .. > -> 'aval with_in : ?mode:int ->
?flags:Unix.open_flag list -> string -> f:(Pervasives.in_channel -> 'a) -> 'aflags : opening flags. Unix.O_RDONLY is used in any casesval with_out : ?mode:int ->
?flags:Unix.open_flag list ->
string -> f:(Pervasives.out_channel -> 'a) -> 'a
flags : opening flags (default [Unix.O_CREAT; Unix.O_TRUNC])
Unix.O_WRONLY is used in any cases.val with_process_in : string -> f:(Pervasives.in_channel -> 'a) -> 'a CCUnix.with_process_in "ls /tmp" ~f:CCIO.read_lines_l;;
val with_process_out : string -> f:(Pervasives.out_channel -> 'a) -> 'atype process_full = <
|
close : |
(* |
Will block until the process stops
| *) |
|
stderr : |
|||
|
stdin : |
|||
|
stdout : |
val with_process_full : ?env:string array -> string -> f:(process_full -> 'a) -> 'aenv : environment to pass to the subprocess.val with_connection : Unix.sockaddr ->
f:(Pervasives.in_channel -> Pervasives.out_channel -> 'a) -> 'aUnix.open_connection with a handlerexception ExitServer
val establish_server : Unix.sockaddr ->
f:(Pervasives.in_channel -> Pervasives.out_channel -> 'a) -> unitThread is recommended if handlers might take time.
The callback should raise CCUnix.ExitServer to stop the loop.module Infix:sig..end
include CCUnix.Infix