Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 143 lines (116 sloc) 3.996 kb
fccc685 Initial open-source release
MLstate authored
1 /*
37af51d @Aqua-Ye [enhance] system: added a fixed value to know the process launch date (G...
Aqua-Ye authored
2 Copyright © 2011, 2012 MLstate
fccc685 Initial open-source release
MLstate authored
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 */
37ce9a6 @OpaOnWindowsNow [enhance] opabsl&plugins: extract browser_canvas,crypto,irc,socket,unix ...
OpaOnWindowsNow authored
18 import-plugin unix
19
fccc685 Initial open-source release
MLstate authored
20 /**
21 * {1 Types defined in this file}
22 **/
23
24 /**
25 * [{ WEXITED : int }]
26 * The process terminated normally by exit ;
27 * the argument is the return code.
28 *
29 * [{ WSIGNALED : int }]
30 * The process was killed by a signal;
31 * the argument is the signal number.
32 *
33 * [{ WSTOPPED : int }]
34 * The process was stopped by a signal;
35 * the argument is the signal number.
36 **/
37 type System.process_status =
38 { WEXITED : int }
39 / { WSIGNALED : int }
40 / { WSTOPPED : int }
41
42 type System.wait_flag = external
43
44 type System.pid = int
45
7442470 @Aqua-Ye [doc] system: moved a comment
Aqua-Ye authored
46 /**
47 * Binding with module System
48 * <!> Not for casual user
49 **/
fccc685 Initial open-source release
MLstate authored
50 System = {{
51
0a95c4c @Aqua-Ye [cleanup] system: indent
Aqua-Ye authored
52 /**
53 * {2 Wait Flags}
54 **/
55
56 WNOHANG = %%bslunix.wnohang%% : System.wait_flag
57 WUNTRACED = %%bslunix.wuntraced%% : System.wait_flag
58
59 /**
60 * {2 Fork}
61 **/
62
63 /**
64 * Fork.
65 * Discouraged, used for quick tests only
66 **/
67 fork = %%bslunix.fork%% : -> System.pid
68
69 /**
70 * Wait until one of the children processes die,
71 * and return its pid and termination status.
72 **/
73 wait = %%bslunix.wait%% : -> (System.pid, System.process_status)
74
75 /**
76 * Same as {!System.wait} , but waits for the child process whose pid is given.
77 * A pid of -1 means wait for any child. A pid of 0 means wait for any
78 * child in the same process group as the current process.
79 * Negative pid arguments represent process groups.
80 * The list of options indicates whether waitpid should return immediately
81 * without waiting, or also report stopped children.
82 **/
83 waitpid_flags = %%bslunix.waitpid_flags%%
84 : caml_list(System.wait_flag), System.pid -> (System.pid, System.process_status)
85
86 /**
87 * Same as {!System.waitpid_flags} but with no flags
88 **/
89 waitpid = %%bslunix.waitpid%% : System.pid -> (System.pid, System.process_status)
90
91
92 /**
93 * Quit the server process immediately.
94 */
95 exit = %% BslSys.exit %% : int -> 'a
96
97 /**
98 * Register a function to be executed whenever the server will exit
99 * Execution will take place following reverse order of registration
100 */
101 at_exit = @may_cps(%% BslScheduler.at_exit %%) : (-> void) -> void
102
103 /**
104 * gethostname() returns the current hostname (see system gethostname)
105 */
106 gethostname = %% BslSys.gethostname %% : -> string
107
108 /**
109 * gethostbyname() returns the ip (v4) for the given hostname using 'hosts' (see system gethostbyname)
110 */
111 gethostbyname = %%BslSys.gethostbyname%% : string -> option(ip)
112
113 /**
114 * gethostsbyname() returns the ips (v4) for the given hostname using 'hosts' (see system gethostbyname)
115 */
116 gethostsbyname = %%BslSys.gethostsbyname%% : string -> list(ip)
117
118 /**
119 * Get the current process memory usage.
120 * @return the memory usage in bytes
121 */
122 get_memory_usage = %%bslSys.get_memory_usage%% : -> int
123
124 /**
125 * Get the curent process launch date.
126 * @return the GMT launch date of the application
127 */
128 gmt_launch_date = Date.now_gmt()
129
130 /**
131 * [exec(command, input)]
132 * acts like: echo input | command > output
133 *
134 * Primitive for calling an external command, and returning the string
135 * built from the resulting stdout of the command, given an input to
136 * produce on the stdin of the process.
137 * In case of error, return the error message instead of the process output.
138 * @return raw result
139 */
140 exec = %%bslSys.process.exec%% : string, string -> string
f4bb8f3 [enhance] system: bsl function Sys.process.exec binded
Nicolas Glondu authored
141
fccc685 Initial open-source release
MLstate authored
142 }}
Something went wrong with that request. Please try again.