1 (***********************************************************************)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the GNU Library General Public License, with *)
10 (* the special exception on linking described in file ../LICENSE. *)
12 (***********************************************************************)
16 (** System interface. *)
18 val argv
: string array
19 (** The command line arguments given to the process.
20 The first element is the command name used to invoke the program.
21 The following elements are the command-line arguments
22 given to the program. *)
24 val executable_name
: string
25 (** The name of the file containing the executable currently running. *)
27 external file_exists
: string -> bool = "caml_sys_file_exists"
28 (** Test if a file with the given name exists. *)
30 external is_directory
: string -> bool = "caml_sys_is_directory"
31 (** Returns [true] if the given name refers to a directory,
32 [false] if it refers to another kind of file.
33 Raise [Sys_error] if no file exists with the given name. *)
35 external remove
: string -> unit = "caml_sys_remove"
36 (** Remove the given file name from the file system. *)
38 external rename
: string -> string -> unit = "caml_sys_rename"
39 (** Rename a file. The first argument is the old name and the
40 second is the new name. If there is already another file
41 under the new name, [rename] may replace it, or raise an
42 exception, depending on your operating system. *)
44 external getenv
: string -> string = "caml_sys_getenv"
45 (** Return the value associated to a variable in the process
46 environment. Raise [Not_found] if the variable is unbound. *)
48 external command
: string -> int = "caml_sys_system_command"
49 (** Execute the given shell command and return its exit code. *)
51 external time
: unit -> float = "caml_sys_time"
52 (** Return the processor time, in seconds, used by the program
53 since the beginning of execution. *)
55 val time_f
: ('a
-> 'b
) -> 'a
-> (float * 'b
)
56 (** [time_f f a] evaluates [f a] and returns what it returns
57 with the processor time difference before and after its
60 external chdir
: string -> unit = "caml_sys_chdir"
61 (** Change the current working directory of the process. *)
63 external getcwd
: unit -> string = "caml_sys_getcwd"
64 (** Return the current working directory of the process. *)
66 external readdir
: string -> string array
= "caml_sys_read_directory"
67 (** Return the names of all files present in the given directory.
68 Names denoting the current directory and the parent directory
69 (["."] and [".."] in Unix) are not returned. Each string in the
70 result is a file name rather than a complete path. There is no
71 guarantee that the name strings in the resulting array will appear
72 in any specific order; they are not, in particular, guaranteed to
73 appear in alphabetical order. *)
75 val interactive
: bool ref
76 (** This reference is initially set to [false] in standalone
77 programs and to [true] if the code is being executed under
78 the interactive toplevel system [ocaml]. *)
81 (** Operating system currently executing the Caml program. One of
82 - ["Unix"] (for all Unix versions, including Linux and Mac OS X),
83 - ["Win32"] (for MS-Windows, OCaml compiled with MSVC++ or Mingw),
84 - ["Cygwin"] (for MS-Windows, OCaml compiled with Cygwin). *)
87 (** Size of one word on the machine currently executing the Caml
88 program, in bits: 32 or 64. *)
90 val max_string_length
: int
91 (** Maximum length of a string. *)
93 val max_array_length
: int
94 (** Maximum length of a normal array. The maximum length of a float
95 array is [max_array_length/2] on 32-bit machines and
96 [max_array_length] on 64-bit machines. *)
99 (** {6 Signal handling} *)
102 type signal_behavior
=
105 | Signal_handle
of (int -> unit)
106 (** What to do when receiving a signal:
107 - [Signal_default]: take the default behavior
108 (usually: abort the program)
109 - [Signal_ignore]: ignore the signal
110 - [Signal_handle f]: call function [f], giving it the signal
111 number as argument. *)
114 int -> signal_behavior
-> signal_behavior
= "caml_install_signal_handler"
115 (** Set the behavior of the system on receipt of a given signal. The
116 first argument is the signal number. Return the behavior
117 previously associated with the signal. If the signal number is
118 invalid (or not available on your system), an [Invalid_argument]
119 exception is raised. *)
121 val set_signal
: int -> signal_behavior
-> unit
122 (** Same as {!Sys.signal} but return value is ignored. *)
125 (** {7 Signal numbers for the standard POSIX signals.} *)
128 (** Abnormal termination *)
134 (** Arithmetic exception *)
137 (** Hangup on controlling terminal *)
140 (** Invalid hardware instruction *)
143 (** Interactive interrupt (ctrl-C) *)
146 (** Termination (cannot be ignored) *)
152 (** Interactive termination *)
155 (** Invalid memory reference *)
161 (** Application-defined signal 1 *)
164 (** Application-defined signal 2 *)
167 (** Child process terminated *)
176 (** Interactive stop *)
179 (** Terminal read from background process *)
182 (** Terminal write from background process *)
185 (** Timeout in virtual time *)
188 (** Profiling interrupt *)
192 (** Exception raised on interactive interrupt if {!Sys.catch_break}
196 val catch_break
: bool -> unit
197 (** [catch_break] governs whether interactive interrupt (ctrl-C)
198 terminates the program or raises the [Break] exception.
199 Call [catch_break true] to enable raising [Break],
200 and [catch_break false] to let the system
201 terminate the program on user interrupt. *)
204 val ocaml_version
: string;;
205 (** [ocaml_version] is the version of Objective Caml.
206 It is a string of the form ["major.minor[.patchlevel][+additional-info]"],
207 where [major], [minor], and [patchlevel] are integers, and
208 [additional-info] is an arbitrary string. The [[.patchlevel]] and
209 [[+additional-info]] parts may be absent. *)