module Channel:sig..end
typedescr =Unix.file_descr
typeany_channel =[ `InChannel of Pervasives.in_channel | `OutChannel of Pervasives.out_channel ]
in_channel and out_channel. Returned by Channel.open_thunk,
Channel.open_command, and Channel.open_program.typegen_in_channel =[ `InChannel of Pervasives.in_channel
| `InDescr of descr
| `InFd of int ]
in_channel and
UNIX file descriptors, both abstract and as ints.typegen_out_channel =[ `OutChannel of Pervasives.out_channel
| `OutDescr of descr
| `OutFd of int ]
out_channel and
UNIX file descriptors, both abstract and as ints.typegen_channel =[ `InChannel of Pervasives.in_channel
| `InDescr of descr
| `InFd of int
| `OutChannel of Pervasives.out_channel
| `OutDescr of descr
| `OutFd of int ]
typedup_in_source =[ `Close
| `Filename of string
| `InChannel of Pervasives.in_channel
| `InDescr of descr
| `InFd of int
| `Null ]
Channel.dup2 (`Filename s, gen) opens the file s on
generalized channel gen.Channel.dup2 (`Close, gen) closes gen.Channel.dup2 (`Null, gen) opens /dev/null for input
on gen.typedup_out_source =[ `Close
| `Filename of string
| `Filespec of string * clobber_spec
| `Null
| `OutChannel of Pervasives.out_channel
| `OutDescr of descr
| `OutFd of int ]
`Filespec allows specifying how an output file is to be
opened according to Channel.clobber_spec.Channel.dup_in_source, except that `Filename uses Channel.clobber
as its open mode.typeclobber_spec =[ `Append | `AppendOnly | `Clobber | `NoClobber ]
Channel.dup_out_source.`Clobber opens the file and truncates it if it exists.`NoClobber fails if the file exists.`Append opens the file for appending and creates it if it doesn't
exist.`AppendOnly opens the file for appending if it exists and fails
otherwise.typedup_source =[ `Close
| `Filename of string
| `Filespec of string * clobber_spec
| `InChannel of Pervasives.in_channel
| `InDescr of descr
| `InFd of int
| `Null
| `OutChannel of Pervasives.out_channel
| `OutDescr of descr
| `OutFd of int ]
typedup_spec =(dup_source * gen_channel) list
typepipe_spec =gen_channel list
typeprocref =Proc.t option Pervasives.ref
Proc.t. Used as an out-parameter
by functions that fork.
val clobber : clobber_spec Pervasives.ref
val descr_of_gen : gen_channel -> descrChannel.descr underlying a generalized channel. Note that if the
channel is a managed in_channel or out_channel, the descriptor
may be closed when the channel is collected.val descr_of_fd : int -> descrval fd_of_descr : descr -> intval open_file_in : string -> Pervasives.in_channelval open_file_out : string -> Pervasives.out_channelval null_in : unit -> Pervasives.in_channel/dev/null for input. Attaches a finalizer.val null_out : unit -> Pervasives.out_channel/dev/null for output. Attaches a finalizer.val close_in : Pervasives.in_channel -> unitval close_out : Pervasives.out_channel -> unitval close_gen : gen_channel -> unitval dup2 : dup_source * gen_channel -> unitChannel.dup2 (src, dest)
copies src to dest so that future operations on dest use src.
If dest is an out_channel, it is flushed first; if dest in an
in_channel, its buffer is discarded.
Some sources have special behaviors; see Channel.dup_in_source and
Channel.dup_out_source.
val mov2 : dup_source * gen_channel -> unitChannel.dup2, but the
source channel is closed after the operation (unless the source and
the destination are the same).val with_dups : dup_spec -> (unit -> 'a) -> 'aval dup_in : dup_in_source -> Pervasives.in_channelin_channel from an input dup source.val dup_out : dup_out_source -> Pervasives.out_channelout_channel from an input dup source.module Dup:sig..end
val open_thunk : ?pipes:pipe_spec ->
?dups:dup_spec -> (unit -> unit) -> Proc.t * any_channel listChannel.open_thunk ~pipes ~dups
thunk forks and calls thunk in the child process. Any given
dups are performed in the child before calling the thunk. Channels
specified in pipes are connected to pipes, and the other ends are
returned in a list, along with the Proc.t of the child process.
The functions Channel.open_thunk_in, Channel.open_thunk_out, Channel.open_thunk2,
and Channel.open_thunk3 are special cases. Rather than return the
Proc.t, they stash it in the optional argument ?procref.
val open_thunk_in : ?procref:procref ->
?dups:dup_spec -> (unit -> unit) -> Pervasives.in_channelstdout.val open_thunk_out : ?procref:procref ->
?dups:dup_spec -> (unit -> unit) -> Pervasives.out_channelstdin.val open_thunk2 : ?procref:procref ->
?dups:dup_spec ->
(unit -> unit) -> Pervasives.in_channel * Pervasives.in_channelstdout and stderr.val open_thunk3 : ?procref:procref ->
?dups:dup_spec ->
(unit -> unit) ->
Pervasives.out_channel * Pervasives.in_channel * Pervasives.in_channelstdin, stdout, and stderr.val open_command : ?pipes:pipe_spec ->
?dups:dup_spec -> string -> Proc.t * any_channel listChannel.open_thunk, but takes a
command to run in the shell.val open_command_in : ?procref:procref ->
?dups:dup_spec -> string -> Pervasives.in_channelstdout.val open_command_out : ?procref:procref ->
?dups:dup_spec -> string -> Pervasives.out_channelstdin.val open_command2 : ?procref:procref ->
?dups:dup_spec ->
string -> Pervasives.in_channel * Pervasives.in_channelstdout and stderr.val open_command3 : ?procref:procref ->
?dups:dup_spec ->
string ->
Pervasives.out_channel * Pervasives.in_channel * Pervasives.in_channelstdin, stdout, and stderr.val open_program : ?pipes:pipe_spec ->
?dups:dup_spec ->
?path:bool ->
string -> ?argv0:string -> string list -> Proc.t * any_channel listChannel.open_thunk, but takes a program and arguments.val open_program_in : ?procref:procref ->
?dups:dup_spec ->
?path:bool -> string -> ?argv0:string -> string list -> Pervasives.in_channelstdout.val open_program_out : ?procref:procref ->
?dups:dup_spec ->
?path:bool ->
string -> ?argv0:string -> string list -> Pervasives.out_channelstdin.val open_program2 : ?procref:procref ->
?dups:dup_spec ->
?path:bool ->
string ->
?argv0:string -> string list -> Pervasives.in_channel * Pervasives.in_channelstdout and stderr.val open_program3 : ?procref:procref ->
?dups:dup_spec ->
?path:bool ->
string ->
?argv0:string ->
string list ->
Pervasives.out_channel * Pervasives.in_channel * Pervasives.in_channelstdin, stdout, and stderr.val string_of_channel : Pervasives.in_channel -> stringval string_of_command : ?procref:procref -> string -> stringval string_of_program : ?procref:procref ->
?path:bool -> string -> ?argv0:string -> string list -> stringval open_string_in : string -> Pervasives.in_channelin_channel whose contents is a given string.val with_out_string : (Pervasives.out_channel -> 'a) -> 'a * stringstdout and returns the return value of the
thunk and the collected output.
These functions correspond directly to those of the same name in the
Unix structure. However, these directory handles are managed by
the garbage collected and thus closed if they become unreachable.
type directory
val opendir : string -> directoryUnix.opendir.val closedir : directory -> unitUnix.closedir.val readdir : directory -> stringUnix.readdir.val rewinddir : directory -> unitUnix.rewinddir.val pp_descr : Format.formatter -> descr -> unitChannel.descr.val pp_in_channel : Format.formatter -> Pervasives.in_channel -> unitin_channel.val pp_out_channel : Format.formatter -> Pervasives.out_channel -> unitout_channel.