1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset= ISO-8859-1">
<TITLE>
Module Sys: system interface
</TITLE>
</HEAD>
<BODY >
<A HREF="manual057.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual059.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<HR>
<H2>17.28 Module <TT>Sys</TT>: system interface</H2><A NAME="s:Sys"></A>
<A NAME="@manual483"></A><PRE>
val argv: string array
</PRE>
<A NAME="@manual484"></A><BLOCKQUOTE>
The command line arguments given to the process.
The first element is the command name used to invoke the program.
The following elements are the command-line arguments
given to the program.
</BLOCKQUOTE>
<PRE>
val file_exists: string -> bool
</PRE>
<A NAME="@manual485"></A><BLOCKQUOTE>
Test if a file with the given name exists.
</BLOCKQUOTE>
<PRE>
val remove: string -> unit
</PRE>
<A NAME="@manual486"></A><BLOCKQUOTE>
Remove the given file name from the file system.
</BLOCKQUOTE>
<PRE>
val rename : string -> string -> unit
</PRE>
<A NAME="@manual487"></A><BLOCKQUOTE>
Rename a file. The first argument is the old name and the
second is the new name.
</BLOCKQUOTE>
<PRE>
val getenv: string -> string
</PRE>
<A NAME="@manual488"></A><BLOCKQUOTE>
Return the value associated to a variable in the process
environment. Raise <CODE>Not_found</CODE> if the variable is unbound.
</BLOCKQUOTE>
<PRE>
val command: string -> int
</PRE>
<A NAME="@manual489"></A><BLOCKQUOTE>
Execute the given shell command and return its exit code.
</BLOCKQUOTE>
<PRE>
val time: unit -> float
</PRE>
<A NAME="@manual490"></A><BLOCKQUOTE>
Return the processor time, in seconds, used by the program
since the beginning of execution.
</BLOCKQUOTE>
<PRE>
val chdir: string -> unit
</PRE>
<A NAME="@manual491"></A><BLOCKQUOTE>
Change the current working directory of the process.
</BLOCKQUOTE>
<PRE>
val getcwd: unit -> string
</PRE>
<A NAME="@manual492"></A><BLOCKQUOTE>
Return the current working directory of the process.
</BLOCKQUOTE>
<PRE>
val interactive: bool ref
</PRE>
<A NAME="@manual493"></A><BLOCKQUOTE>
This reference is initially set to <CODE>false</CODE> in standalone
programs and to <CODE>true</CODE> if the code is being executed under
the interactive toplevel system <CODE>ocaml</CODE>.
</BLOCKQUOTE>
<PRE>
val os_type: string
</PRE>
<A NAME="@manual494"></A><BLOCKQUOTE>
Operating system currently executing the Caml program.
One of <CODE>"Unix"</CODE>, <CODE>"Win32"</CODE>, or <CODE>"MacOS"</CODE>.
</BLOCKQUOTE>
<PRE>
val word_size: int
</PRE>
<A NAME="@manual495"></A><BLOCKQUOTE>
Size of one word on the machine currently executing the Caml
program, in bits: 32 or 64.
</BLOCKQUOTE>
<PRE>
val max_string_length: int
</PRE>
<A NAME="@manual496"></A><BLOCKQUOTE>
Maximum length of a string.
</BLOCKQUOTE>
<PRE>
val max_array_length: int
</PRE>
<A NAME="@manual497"></A><BLOCKQUOTE>
Maximum length of an array.
</BLOCKQUOTE>
<H3>Signal handling </H3>
<PRE>
type signal_behavior =
Signal_default
| Signal_ignore
| Signal_handle of (int -> unit)
</PRE>
<BLOCKQUOTE>
What to do when receiving a signal:<BR><CODE>Signal_default</CODE>: take the default behavior
(usually: abort the program)<BR><CODE>Signal_ignore</CODE>: ignore the signal<BR><CODE>Signal_handle f</CODE>: call function <CODE>f</CODE>, giving it the signal
number as argument.
</BLOCKQUOTE>
<PRE>
val signal: int -> signal_behavior -> signal_behavior
</PRE>
<A NAME="@manual498"></A><BLOCKQUOTE>
Set the behavior of the system on receipt of a given signal.
The first argument is the signal number. Return the behavior
previously associated with the signal.
</BLOCKQUOTE>
<PRE>
val set_signal: int -> signal_behavior -> unit
</PRE>
<A NAME="@manual499"></A><BLOCKQUOTE>
Same as <CODE>signal</CODE> but return value is ignored.
</BLOCKQUOTE>
<PRE>
val sigabrt: int (* Abnormal termination *)
val sigalrm: int (* Timeout *)
val sigfpe: int (* Arithmetic exception *)
val sighup: int (* Hangup on controlling terminal *)
val sigill: int (* Invalid hardware instruction *)
val sigint: int (* Interactive interrupt (ctrl-C) *)
val sigkill: int (* Termination (cannot be ignored) *)
val sigpipe: int (* Broken pipe *)
val sigquit: int (* Interactive termination *)
val sigsegv: int (* Invalid memory reference *)
val sigterm: int (* Termination *)
val sigusr1: int (* Application-defined signal 1 *)
val sigusr2: int (* Application-defined signal 2 *)
val sigchld: int (* Child process terminated *)
val sigcont: int (* Continue *)
val sigstop: int (* Stop *)
val sigtstp: int (* Interactive stop *)
val sigttin: int (* Terminal read from background process *)
val sigttou: int (* Terminal write from background process *)
val sigvtalrm: int (* Timeout in virtual time *)
val sigprof: int (* Profiling interrupt *)
</PRE>
<A NAME="@manual500"></A><A NAME="@manual501"></A><A NAME="@manual502"></A><A NAME="@manual503"></A><A NAME="@manual504"></A><A NAME="@manual505"></A><A NAME="@manual506"></A><A NAME="@manual507"></A><A NAME="@manual508"></A><A NAME="@manual509"></A><A NAME="@manual510"></A><A NAME="@manual511"></A><A NAME="@manual512"></A><A NAME="@manual513"></A><A NAME="@manual514"></A><A NAME="@manual515"></A><A NAME="@manual516"></A><A NAME="@manual517"></A><A NAME="@manual518"></A><A NAME="@manual519"></A><A NAME="@manual520"></A><BLOCKQUOTE>
Signal numbers for the standard POSIX signals.
</BLOCKQUOTE>
<PRE>
exception Break
</PRE>
<A NAME="@manual521"></A><BLOCKQUOTE>
Exception raised on interactive interrupt if <CODE>catch_break</CODE>
is on.
</BLOCKQUOTE>
<PRE>
val catch_break: bool -> unit
</PRE>
<A NAME="@manual522"></A><BLOCKQUOTE>
<CODE>catch_break</CODE> governs whether interactive interrupt (ctrl-C)
terminates the program or raises the <CODE>Break</CODE> exception.
Call <CODE>catch_break true</CODE> to enable raising <CODE>Break</CODE>,
and <CODE>catch_break false</CODE> to let the system
terminate the program on user interrupt.
</BLOCKQUOTE>
<HR>
<A HREF="manual057.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual059.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
</BODY>
</HTML>
|