1996-04-29 06:25:10 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1996-04-29 06:25:10 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the GNU Library General Public License. *)
|
1996-04-29 06:25:10 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
|
|
|
(* Module [ThreadUnix]: thread-compatible system calls *)
|
|
|
|
|
|
|
|
(* This module reimplements some of the functions from [Unix]
|
|
|
|
so that they only block the calling thread, not all threads
|
|
|
|
in the program, if they cannot complete immediately.
|
|
|
|
See the documentation of the [Unix] module for more
|
|
|
|
precise descriptions of the functions below. *)
|
|
|
|
|
|
|
|
(*** Process handling *)
|
|
|
|
|
1999-11-30 08:07:38 -08:00
|
|
|
val execv : prog:string -> args:string array -> unit
|
|
|
|
val execve : prog:string -> args:string array -> env:string array -> unit
|
|
|
|
val execvp : prog:string -> args:string array -> unit
|
1996-04-29 06:25:10 -07:00
|
|
|
val wait : unit -> int * Unix.process_status
|
1999-11-30 08:07:38 -08:00
|
|
|
val waitpid : flags:Unix.wait_flag list -> int -> int * Unix.process_status
|
1996-04-29 06:25:10 -07:00
|
|
|
val system : string -> Unix.process_status
|
|
|
|
|
|
|
|
(*** Basic input/output *)
|
|
|
|
|
2000-01-31 21:43:25 -08:00
|
|
|
val read : Unix.file_descr -> buf:string -> pos:int -> len:int -> int
|
|
|
|
val write : Unix.file_descr -> buf:string -> pos:int -> len:int -> int
|
1996-04-29 06:25:10 -07:00
|
|
|
|
|
|
|
(*** Input/output with timeout *)
|
|
|
|
|
1999-11-30 08:07:38 -08:00
|
|
|
val timed_read :
|
|
|
|
Unix.file_descr ->
|
2000-01-31 21:43:25 -08:00
|
|
|
buf:string -> pos:int -> len:int -> timeout:float -> int
|
1999-11-30 08:07:38 -08:00
|
|
|
val timed_write :
|
|
|
|
Unix.file_descr ->
|
2000-01-31 21:43:25 -08:00
|
|
|
buf:string -> pos:int -> len:int -> timeout:float -> int
|
2000-01-07 08:05:19 -08:00
|
|
|
(* Behave as [read] and [write], except that
|
1996-04-29 06:25:10 -07:00
|
|
|
[Unix_error(ETIMEDOUT,_,_)] is raised if no data is
|
|
|
|
available for reading or ready for writing after [d] seconds.
|
|
|
|
The delay [d] is given in the fifth argument, in seconds. *)
|
|
|
|
|
1997-04-11 06:57:34 -07:00
|
|
|
(*** Polling *)
|
|
|
|
|
|
|
|
val select :
|
1999-11-30 08:07:38 -08:00
|
|
|
read:Unix.file_descr list -> write:Unix.file_descr list ->
|
2000-01-31 22:52:39 -08:00
|
|
|
except:Unix.file_descr list -> timeout:float ->
|
1997-04-11 06:57:34 -07:00
|
|
|
Unix.file_descr list * Unix.file_descr list * Unix.file_descr list
|
|
|
|
|
1996-04-29 06:25:10 -07:00
|
|
|
(*** Pipes and redirections *)
|
|
|
|
|
|
|
|
val pipe : unit -> Unix.file_descr * Unix.file_descr
|
|
|
|
val open_process_out: string -> out_channel
|
|
|
|
val open_process: string -> in_channel * out_channel
|
|
|
|
|
|
|
|
(*** Time *)
|
|
|
|
|
|
|
|
val sleep : int -> unit
|
|
|
|
|
|
|
|
(*** Sockets *)
|
|
|
|
|
1999-11-30 08:07:38 -08:00
|
|
|
val socket : domain:Unix.socket_domain ->
|
2000-01-07 08:05:19 -08:00
|
|
|
type:Unix.socket_type -> proto:int -> Unix.file_descr
|
1999-11-30 08:07:38 -08:00
|
|
|
val socketpair : domain:Unix.socket_domain -> type:Unix.socket_type ->
|
2000-01-07 08:05:19 -08:00
|
|
|
proto:int -> Unix.file_descr * Unix.file_descr
|
1996-04-29 06:25:10 -07:00
|
|
|
val accept : Unix.file_descr -> Unix.file_descr * Unix.sockaddr
|
|
|
|
val connect : Unix.file_descr -> Unix.sockaddr -> unit
|
2000-01-31 21:43:25 -08:00
|
|
|
val recv : Unix.file_descr -> buf:string ->
|
2000-01-07 08:05:19 -08:00
|
|
|
pos:int -> len:int -> flags:Unix.msg_flag list -> int
|
2000-01-31 21:43:25 -08:00
|
|
|
val recvfrom : Unix.file_descr -> buf:string -> pos:int -> len:int ->
|
1999-11-30 08:07:38 -08:00
|
|
|
flags:Unix.msg_flag list -> int * Unix.sockaddr
|
2000-01-31 21:43:25 -08:00
|
|
|
val send : Unix.file_descr -> buf:string -> pos:int -> len:int ->
|
1999-11-30 08:07:38 -08:00
|
|
|
flags:Unix.msg_flag list -> int
|
2000-01-31 21:43:25 -08:00
|
|
|
val sendto : Unix.file_descr -> buf:string -> pos:int -> len:int ->
|
1999-11-30 08:07:38 -08:00
|
|
|
flags:Unix.msg_flag list -> addr:Unix.sockaddr -> int
|
1996-04-29 06:25:10 -07:00
|
|
|
val open_connection : Unix.sockaddr -> in_channel * out_channel
|
|
|
|
val establish_server :
|
1999-11-30 08:07:38 -08:00
|
|
|
fun:(in:in_channel -> out:out_channel -> 'a) ->
|
|
|
|
addr:Unix.sockaddr -> unit
|