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