Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

69 lines (52 sloc) 2.313 kB
(*
Copyright © 2011 MLstate
This file is part of OPA.
OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
(**
Binding with module Unix
<!> Not for casual user
*)
(* refactoring in progress *)
module BslNativeLib = BslNativeLib
##opa-type System.process_status
##extern-type System.wait_flag = Unix.wait_flag
##register wnohang \ `Unix.WNOHANG` : System.wait_flag
##register wuntraced \ `Unix.WUNTRACED` : System.wait_flag
##register fork \ `Unix.fork` : -> int
let field_WEXITED = ServerLib.static_field_of_name "WEXITED"
let field_WSIGNALED = ServerLib.static_field_of_name "WSIGNALED"
let field_WSTOPPED = ServerLib.static_field_of_name "WSTOPPED"
let make_opa_status field i =
let record = ServerLib.empty_record_constructor in
let record = ServerLib.add_field record field (ServerLib.wrap_int i) in
let record = ServerLib.make_record record in
wrap_opa_system_process_status record
let opa_status = function
| Unix.WEXITED i -> make_opa_status field_WEXITED i
| Unix.WSIGNALED i -> make_opa_status field_WSIGNALED i
| Unix.WSTOPPED i -> make_opa_status field_WSTOPPED i
let return_pid_status (pid, status) =
let pid = ServerLib.wrap_int pid in
let status = opa_status status in
BslNativeLib.opa_tuple_2 (pid, status)
##register wait : -> opa[tuple_2(int, System.process_status)]
let wait () =
let pid_status = Unix.wait () in
return_pid_status pid_status
##register waitpid_flags : caml_list(System.wait_flag), int -> opa[tuple_2(int, System.process_status)]
let waitpid_flags flags pid =
let pid_status = Unix.waitpid flags pid in
return_pid_status pid_status
##register waitpid : int -> opa[tuple_2(int, System.process_status)]
let waitpid pid =
let pid_status = Unix.waitpid [] pid in
return_pid_status pid_status
Jump to Line
Something went wrong with that request. Please try again.