1Sys(3)                           OCaml library                          Sys(3)
2
3
4

NAME

6       Sys - System interface.
7

Module

9       Module   Sys
10

Documentation

12       Module Sys
13        : sig end
14
15
16       System interface.
17
18
19
20
21
22
23
24       val argv : string array
25
26       The  command line arguments given to the process.  The first element is
27       the command name used to invoke the program.   The  following  elements
28       are the command-line arguments given to the program.
29
30
31
32
33       val executable_name : string
34
35       The name of the file containing the executable currently running.
36
37
38
39
40       val file_exists : string -> bool
41
42       Test if a file with the given name exists.
43
44
45
46
47       val is_directory : string -> bool
48
49       Returns  true  if  the  given  name  refers to a directory, false if it
50       refers to another kind of file.  Raise Sys_error if no file exists with
51       the given name.
52
53
54
55
56       val remove : string -> unit
57
58       Remove the given file name from the file system.
59
60
61
62
63       val rename : string -> string -> unit
64
65       Rename a file. The first argument is the old name and the second is the
66       new name. If there is already another file under the new  name,  rename
67       may replace it, or raise an exception, depending on your operating sys‐
68       tem.
69
70
71
72
73       val getenv : string -> string
74
75       Return the value associated to a variable in the  process  environment.
76       Raise Not_found if the variable is unbound.
77
78
79
80
81       val command : string -> int
82
83       Execute the given shell command and return its exit code.
84
85
86
87
88       val time : unit -> float
89
90       Return  the  processor  time, in seconds, used by the program since the
91       beginning of execution.
92
93
94
95
96       val chdir : string -> unit
97
98       Change the current working directory of the process.
99
100
101
102
103       val getcwd : unit -> string
104
105       Return the current working directory of the process.
106
107
108
109
110       val readdir : string -> string array
111
112       Return the names of all files present in the  given  directory.   Names
113       denoting the current directory and the parent directory ( .  and ..  in
114       Unix) are not returned.  Each string in  the  result  is  a  file  name
115       rather  than  a  complete  path.   There  is no guarantee that the name
116       strings in the resulting array will appear in any specific order;  they
117       are not, in particular, guaranteed to appear in alphabetical order.
118
119
120
121
122       val interactive : bool Pervasives.ref
123
124       This  reference is initially set to false in standalone programs and to
125       true if the code is being executed under the interactive toplevel  sys‐
126       tem ocaml .
127
128
129
130
131       val os_type : string
132
133       Operating system currently executing the Caml program. One of
134
135       - Unix (for all Unix versions, including Linux and Mac OS X),
136
137       - Win32 (for MS-Windows, OCaml compiled with MSVC++ or Mingw),
138
139       - Cygwin (for MS-Windows, OCaml compiled with Cygwin).
140
141
142
143
144
145       val word_size : int
146
147       Size  of  one word on the machine currently executing the Caml program,
148       in bits: 32 or 64.
149
150
151
152
153       val max_string_length : int
154
155       Maximum length of a string.
156
157
158
159
160       val max_array_length : int
161
162       Maximum length of a normal array.  The maximum length of a float  array
163       is max_array_length/2 on 32-bit machines and max_array_length on 64-bit
164       machines.
165
166
167
168
169
170       === Signal handling ===
171
172
173       type signal_behavior =
174        | Signal_default
175        | Signal_ignore
176        | Signal_handle of (int -> unit)  (* What to do when receiving a  sig‐
177       nal:
178
179       -  Signal_default  : take the default behavior (usually: abort the pro‐
180       gram)
181
182       - Signal_ignore : ignore the signal
183
184       - Signal_handle f : call function f , giving it the  signal  number  as
185       argument.
186        *)
187
188
189
190
191
192       val signal : int -> signal_behavior -> signal_behavior
193
194       Set the behavior of the system on receipt of a given signal.  The first
195       argument is the signal number.  Return the behavior previously  associ‐
196       ated with the signal. If the signal number is invalid (or not available
197       on your system), an Invalid_argument exception is raised.
198
199
200
201
202       val set_signal : int -> signal_behavior -> unit
203
204       Same as Sys.signal but return value is ignored.
205
206
207
208
209
210       === Signal numbers for the standard POSIX signals.  ===
211
212
213       val sigabrt : int
214
215       Abnormal termination
216
217
218
219
220       val sigalrm : int
221
222       Timeout
223
224
225
226
227       val sigfpe : int
228
229       Arithmetic exception
230
231
232
233
234       val sighup : int
235
236       Hangup on controlling terminal
237
238
239
240
241       val sigill : int
242
243       Invalid hardware instruction
244
245
246
247
248       val sigint : int
249
250       Interactive interrupt (ctrl-C)
251
252
253
254
255       val sigkill : int
256
257       Termination (cannot be ignored)
258
259
260
261
262       val sigpipe : int
263
264       Broken pipe
265
266
267
268
269       val sigquit : int
270
271       Interactive termination
272
273
274
275
276       val sigsegv : int
277
278       Invalid memory reference
279
280
281
282
283       val sigterm : int
284
285       Termination
286
287
288
289
290       val sigusr1 : int
291
292       Application-defined signal 1
293
294
295
296
297       val sigusr2 : int
298
299       Application-defined signal 2
300
301
302
303
304       val sigchld : int
305
306       Child process terminated
307
308
309
310
311       val sigcont : int
312
313       Continue
314
315
316
317
318       val sigstop : int
319
320       Stop
321
322
323
324
325       val sigtstp : int
326
327       Interactive stop
328
329
330
331
332       val sigttin : int
333
334       Terminal read from background process
335
336
337
338
339       val sigttou : int
340
341       Terminal write from background process
342
343
344
345
346       val sigvtalrm : int
347
348       Timeout in virtual time
349
350
351
352
353       val sigprof : int
354
355       Profiling interrupt
356
357
358
359
360       exception Break
361
362
363       Exception raised on interactive interrupt if Sys.catch_break is on.
364
365
366
367
368       val catch_break : bool -> unit
369
370
371       catch_break governs whether interactive interrupt  (ctrl-C)  terminates
372       the  program  or  raises the Break exception.  Call catch_break true to
373       enable raising Break , and catch_break false to let the  system  termi‐
374       nate the program on user interrupt.
375
376
377
378
379       val ocaml_version : string
380
381
382       ocaml_version  is the version of Objective Caml.  It is a string of the
383       form major.minor[.patchlevel][+additional-info] , where major , minor ,
384       and  patchlevel  are  integers,  and  additional-info  is  an arbitrary
385       string. The [.patchlevel] and [+additional-info] parts may be absent.
386
387
388
389
390
391
392OCamldoc                          2010-01-29                            Sys(3)
Impressum